Article

Home » Design and Layout » Flash Tutorials » Flash Script - Scrolling Image Gallery

About the Author

SitePoint

View all articles by SitePoint...

Flash Script - Scrolling Image Gallery

By SitePoint

April 28th, 2003

Reader Rating: 6.5

Download the sample files here.

1. Create a blank movie clip, and give it an instance name of "drag".

2. I've used a square movieclip and simply made 5 instances of the same clip. For the sake of file size, I've used a plain movie clip, but of course, you can use images instead.

Convert each image into a movie clip, and give each instance a name, such as "a1", "a2", "a3", "a4", and "a5".

3. Go to the time line of the "drag" movie clip, and create two key frames.

4. In the first key frame, insert the action:

mw = getProperty("/a1",_width);  
for(i=5; i>=1; i--)  
{  
mx = getProperty("/a"add i,_x);  

//right side  
if(mx > 400)  
{  
if(i==5){mv=1};  
if(i==4){mv=5};  
if(i==3){mv=4};  
if(i==2){mv=3};  
if(i==1){mv=2};  
mx = getProperty("/a"add mv,_x);  
setProperty("/a" add i,_x,mx - (mw + 2));  
}  

//left side  
if(mx < 0)  
{  
if(i==1){mv=5};  
if(i==2){mv=1};  
if(i==3){mv=2};  
if(i==4){mv=3};  
if(i==5){mv=4};  
mw = getProperty("/a"add mv,_width);  
mx = getProperty("/a"add mv,_x);  
setProperty("/a" add i,_x,mx + (mw + 2));  
}  
}

5. In the second key frame, insert the action:

gotoAndPlay (1);

6. Go to the main timeline, create a new layer, and name it "actions".

7. Create three keyframes in the "actions" layer.

1083_tool2

8. In the first key frame, insert the action:

mx = getProperty("/a1",_x);  
mw = getProperty("/a1",_width);  
nomc = 5;

9. Insert the following action into the second key frame:

mc = _root.drag._x  
if (mc>0 and mc<180)  
{  
for (i=1; i<=nomc; i++)  
{  
mx = getProperty("/a" add i, _x);  
setProperty ("/a" add i, _x, mx+10);  
}  
}  
if (mc>220 and mc<400)  
{  
for (i=1; i<=nomc; i++)  
{  
mx = getProperty("/a" add i, _x);  
setProperty ("/a" add i, _x, mx-10);  
}  
}

10. In the third key frame, insert:

gotoAndPlay (2);

12. You're done! Press ctrl+enter to test the movie.

If you liked this article, share the love:
Print-Friendly Version Suggest an Article

Sponsored Links

Rate This Article

  • 1
    Poor
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
    Great

Comment on This Article

Have something to say?

Post A Comment

You need to be a member of the SitePoint Forums to comment on this post. Sign Up

Already a member? Post using your SitePoint Forums account: