Flash Tutorials Photoshop Tutorials Flash Games Flash Game Design
Step 6.
This is the final part of this Flash tutorial to create a gallery with a triple scroll transition. Now that we've created the template for the gallery and imported the images, it's time to write the actionscript. So, create a new layer called "script"
 
Step 7.
Code Explanation:

Line 1-3: Create an array called order. When we attach the images, 3 copies of each image will be attached - One for the top, middle and bottom. 3 masks will also be attached for each image to divide them into segments. A 2D array (Arrays within an array) is used to hold the order of each image segment. The numbers have been rearranged so that none of the images will be alligned properly, when the gallery is first dispalyed.

Step 8.
Code Explanation:

Line 4: A for loop is created to create an empty MC for the 3 rows of images. The "j" in the loop will start off at 0 and increment by 1 (j++), while j is below 3 (i<order.length). If we had 10 images we would set this to j <10.

Line 5: As the "j" increments, the variable "i" (line 5) will equal one of the empty MC's. So, when j is 1, "i" will hold the path of images1.

Line 6: We also need to attach a mask over each empty MC

Line 7: The x poistion of the mask is set,

Line 8 : Each row of images will have a target x position to go to each time a thumbnail is pressed. The initial target is set 1 pixel before where the mask is placed.

Line 9 : A loop is used to place each meask segment 90 below the previous one.

Line 10 : The images are placed at a Y position of 57,

Line 11: The mask MC is set to mask the image (i)

 
Step 9.
Code Explanation:

Line 13: Another loop is used to attach a version of each image to each images MC (image0 -image2). Using "j" from the previous loop and "k" from this loop, the "order" array is looped through to attach the image number from the library.

Line 14 : We use the temp variable "i", holding the path of the images0 - image2, to attach them images. We store the new path in the img variable.

Line 15 : Each image is placed on an X position, using the images width multiplied by the increment K number.

Step 10.
Code Explanation:

Line 17: We use a temporary "thumb" variable to hold the name of each thumb associated with the image position.

Line 18 : The thumbnail is given a property (3 in total) for each position images0 - images2 must move to in order to display an alligned image.

Line 19 - 23: An onPress function is created to set the variables target0 - target2 to equal the stored positions that will make the thumbnails associated image alligned.

Step 11.
Code Explanation:

Line 24 - 31: 2 functions are created to increase and decrease the opacity of the thumbnails, as they are rolled over and rolled out.

Step 12.
Code Explanation:

Line 32 - 34: The targets are set to equal the positions to display image4, which is stored in thumb4.pos2 - thub4.pos2

Line 35 : A speed variable is set for how fast the images scroll.

Line 36 : An onEnterFrame function is created which will execute any code inbetween the braces {} repeatedly, at the frame rate (30) of the movie.

Line 37 - 39 : This is the code used to move "images0" - "images2" MC to the "target" value minus the images current X position divided by the speed, whenever a thumb is pressed.

And that brings us to the end of this Flash tutorial ! Download FLA
 
More Flash Tutorials
 
 
     
     
 
Navigation
Flash Tutorials
Photoshop Tutorials
Flash Games
War Games
 
 
 
 
 
 
 
Top Flash
Create a Spot the Difference Game
Create a Shooter Game
Flash Gallery Tutorial
Flash Website Tutorial
Flash Glitter Graphic
 
 
 
 
 
 
Game Websites
Happy Wheels
Tower Defense Games
Hunting Games
Mario
 
 
 
 
 
 
 
 
     
Site Copyright © 2006 - 2011 Nick DS. All rights reserved.