Friday, October 17, 2008

Creating the Thumbnails With Actionscript

Part 6) Adding the Image & Creating the Thumbnails With Actionscript

Step 16.
In the previous part the box masks were created with Actionscript. In the final part we'll be writing the rest of the actionscript to add the images and create functional thumbnails. So, here is rest of the code explained:

Line 59: The add images function is created
Line 60: A for loop is created which loops while k is below the image total
Line 61 - 62: Each main image in the library is attached to the 'top' empty MC, and assigned to the temporary variable 'm'. The depth variable is increased by 1.
Line 63 - 64: Another instance of each image is then attached to the 'bottom' empty MC, and assigned to the temporary variable 'b'. The depth variable is increased by 1.
Line 65 - 66: Both m and b's position ares then set, so that they're aligned horizontally, in order of number.

Step 17.
Line 67 - 68: Each thumbnail image is then attached and assigned to the variable t. The depth is then increased
Line 69 - 70: It's position is set.
Line 71: Each thumbnails is assigned the position (pos) , that it's corresponding main image should be placeded, when it's pressed.
Line 72: The thumbnail is given an onPress function
Line 73 - 74: newPos is checked to see if it doesn't equal the thumbnails pos attribute, and 'shrink' is checked to see if it's false.
Line 75: If these conditions are met, the bottom MC needs to be moved, so that the currently showing mc can transition out (shrink with squares)
Line 76: Shrink is set to true.

Step 18.

Line 82 - 83: The boxes and images are added
Line 84 - 85: this.onEnterFrame = function(){ } "is a function which will repeatedly run any code we put in between the braces {}, at the frame rate of the SWF file. It's used to check if to shrink the boxes, maskign the top MC.

No comments: