Photo Browser
This project was re-written using classes. The main part of the original image browser script was kept in tact. The improvement to this project involves the addition of a dynamically created thumbnail browser. This browser eliminates the need for smaller thumbnail size images to be imported into the movie. It also eliminates the need to create empty movie clips on the main stage in the flash editor. The Thumb class creates both the movie clips and the thumbnails dynamically.
The thumbnail browser was created using an array identical to the main browser’s pixNames array. To create the thumbnails, the Thumb class constructor creates an empty movie clip, loads an image into it, resizes the images to 10% of its original size, and then moves the image into its place on the screen. The thumbnail’s position is determined by the xposition and yposition variables. If the xposition is greater than the width of the screen, a second row is created by increasing the yposition and resetting the xposition. All of these operations are contained in a for-loop that executes once for each of the pictures in the pixNames array.
To make theses images clickable, two arrays named xClickArea and yClickArea are created in the thumbnail creation loop. These arrays contains x and y coordinates for each of the thumbnails. When the onRelease function is called (the user clicks in the thumbnail area), the _xmouse and _ymouse properties are compared with the xClickArea and YClickArea, which determines which image has been selected.
Finally, to highlight which thumbnail images is being displayed, a ‘highLightCurrent’ function is called, which dynamically draws a red box around the thumbnail using the Drawing API methods in ActionSript.