all groups > flash actionscript > february 2006 >
You're in the

flash actionscript

group:

duplicate a movie clip for a image scroller


duplicate a movie clip for a image scroller andy ga
2/28/2006 9:41:49 PM
flash actionscript: i have an image scroller that moves left or right depending on the position of
the mouse.

the image scroller is a movie clip with the instance name "photo".

once the scroller reaches the left or right edge of the movie clip . . . it
stops scrolling . . . obviously.

i need to figure out a proper way in which this image scroller can duplicate
itself once it reaches either of its' edges, so that it scrolls continuously .
.. . for example, you are about to reach the right edge of the movie clip, &
once you do, the left edge of the movie clip continues where the right edge
would end . . . sort of like a wheel effect (only this is a vertical strip) in
that it will continue to roll infinitely.

I would appreciate it if any experts out there could look through the file
quickly & give me some advice on how to go about doing this within the code
below. You can grab a link to .fla source file at the bottom of this post.

anyways, here is the actionscripting . . .

This is all on the first frame of the main timeline:

// Xphoto = startposition of the scroll image
xphoto = 0;
//
// Widthmovie = This variable hase to be set to the
// same amount of the moviewidth
widthmovie = 325;
//
// Scrollspeed = The scrollspeed of the image (high numbers result in slow
scrolls 10=average)
scrollspeed = 15;
//
// widthphoto = the width of your scrollable image in pixels
widthphoto = 1182;

This is all on the second frame:

// Setting the xmouse to 0 in the centre of the movie:
xmouse = _xmouse - (widthmovie / 2);
// Setting the speed:
speed = (xmouse) / scrollspeed;
// If the speed is negative, the speed will be made positive here:
if (speed < 0) {
speed = -(speed);
}
// If the mouse moves to left, the photo will scroll to the right:
// (That makes sense.... Doesn't it!! ;-)
if (xmouse < 0) {
xphoto = xphoto + speed;
}
// If the mouse moves to the right, the photo will scroll to the left:
if (xmouse > 0) {
xphoto = xphoto - speed;
}


// Checking for the left end of the image:
if (xphoto > 0) {
xphoto = 0;
}
// Checking for the right end of the image:
if (xphoto < -(widthphoto - widthmovie)) {
xphoto = -(widthphoto - widthmovie);
}
// Placing the moviclip (photo) on it's new postition:
setProperty("photo", _x, xphoto);

The third & final frame of the main timeline contains:

gotoAndPlay(2);

Other than that . . . all there is the movie clip "photo", which does contain
buttons with actionscripting for it's rollovers & getURL's (which doesn't
relate to the issue).

Thanks in advance.

Right click save target as for the:
http://erbygrby.net/Photoscroller_15.fla
You can also see the swf:
http://erbygrby.net/Photoscroller_15.swf
Re: duplicate a movie clip for a image scroller blemmo
2/28/2006 11:26:37 PM
Have a look at http://mannometer.homeip.net/flash/endless_mc.html, I think that's the effect you want.

cheers,
Re: duplicate a movie clip for a image scroller andy ga
3/1/2006 12:42:11 AM
yes . . . that is exactly the effect that i wanted . . . thank you so much!

the thing is though . . . i've been trying to get your bit of code to work
with what was in the original script.

i changed the instance name of the photoscroller to "mc" as it was in your
file, & then tried inserting the code into a bunch
of different places within my file, but none of them worked correctly.

could you tell me the proper place to put it & what i should be taking out . .
..

there is a link to the source file in my first post . . .
Re: duplicate a movie clip for a image scroller blemmo
3/1/2006 1:13:55 AM
The code has to be on a frame within the timeline that contains the MC's
instance. The MC has to be on stage in that frame and properly named. It
affects the MC also in the frames after that, as long as it has the right name.

greets,
blemmo
AddThis Social Bookmark Button