Alexander James King

14th March 2009

Scrolling along a photo within a window - Flash / AS3

Here's a quick example I did of moving along a photo with a mouse listener and timer. For when you want to display a widescreen photo and use buttons to navigate along the photo.

There are 3 objects on the stage, 2 buttons (left and right) and a photo.

As the user hovers over the buttons the photo is moved in the opposite direction to scroll across the photo - with a check in there to ensure the user cannot scroll beyond the edges of the photo.

At present it moves 1px at a time - if you wanted to move larger distances this could be changed to use TweenLite rather than incrementing or decrementing the x position of the photo

Download the src files (Main.fla and Main.as)

<< Return to the blog

© 2009 Alexander James King