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