• home
  • forum
  • my
  • kt
  • download
  • Create a Gallery

    Author: 2007-06-06 08:40:59 From:

    Step 1.
    First off create a new Flash document and make dimensions and color as shown below.
     
    Step 2.
    For this tutorial I'm using thumbnails sized 64 width x 56 height, with the main image being 320x280 (image a). All the images used in this tutorial are from the free stock photography site:
    a) Sample Images b) Library
     
    Step 3.
    Next, place thumb-0, thumb-1 on a layer called "thumbs" and the larger image on a layer called "gallery".
     
    Step 4.

    Convert each of the thumbnails to MCs (Movie Clips), by clicking them and pressing F8, and move them to the positions shown in image a) and b). You don't need to convert the large image to an MC because we're going to attach them dynamically using ActionScript later on. Just place it at the position, shown in image c), so that you can create the background around it in the next step.

    a ) b)  c)
     
    Step 5.

    Double click on the rectangle tool, from the tool bar, and set the corner radius to 10

     
    Step 6.
    Creat a dark blue rectangle on a layer below the images and then create a white rectangle below the blue one.
     

    Step 10.
    Next, create a rectangle, with the dimensions shown below, and convert it to an MC called "mask", giving it the same identifier. We will be setting the mask dynamically also. Now go to Part 3 of this Flash tutorial, where we will now write the Actionscript. 

    Step 11.
    This is the final part of this Flash tutorial, where you'll be shown how to make the gallery functional with Actionscript.
    Code Explanation:

    Line 1: An empty MC is created called "images", which we'll attach all the large images to. This will allow us to scroll all the images by just moving "images". 100 is for the level it's placed on.

    Line 2: The "mask" MC is attached and given the same instance name. The mask is placed level 101, which will make it above "images" on the stage.

    Line 3: The mask and images MC's X position are set to 305, which is the center of the large rounded rectangle that we created earlier. This can also be wrtten as:

    Line 4: The mask's Y position is set to 96, which will center it along the Y axis. A variable called "target" is set to 96 instead "images". We can use this to make the images scroll down as soon as it loads, making it more interesting.

    Line 5: "Images" Y position is set to start at -1000.

    Line 6: The "mask" MC is set as the mask over "images".

    Line 7: A sped is set, for how many pixels the images shall move each frame.

     
    Step 12.
    Code Explanation:

    Line 8: A for loop is created to loop to attach each large image. The "i" in the loop will start off at 0 and increment by 1 (i++), while i is below 8 (i<8). If we had 10 images we would set this to i<11.

    Line 9: Using the loop, each image is attached, by referencing the identifier that we gave each image MC earlier. Each image is assigned to a temporary variable called "img", that we can use as short hand to set the properties of the image.

    Line 10: The image's Y position is set using it's height and multiplying it by the incrementing "i" in the loop. So since the each image is 320 in height, image0 will be placed at 0 (0x320) Y position in the "images" empty MC. Image1 will be placed 320 (1X320), Image2 will be placed at 640 (2x320) and so on, until "i" has reached 7.

    Line 11: Each thumbnail is refered to using this["thumb"+i]. The For loop increments "i", so each button will be referenced.

    Line 12: The temporary variable "thumb" is used to set each thumbnail to have an opacity of 60%.

    Line 13: Each thumbnail is then assigned a pos (position) property which will be the position that the "images" MC will move to when the thumbnail is pressed.

    Line 14: Each thumbnail is then given an onPress function.

    Line 15: When the any of the thumbnails is pressed the target variable is to the position of the pos property that was set earlier. This value can then be used to move the "images" MC to it.

    Step 13.
    Code Explanation:

    Line 17 & 18; Next we apply an onRollOver function to each thumbnail, so that it's opacity change to 100%, when it's rolled over.

    Line 20 & 21; An onRollOut function is created to make the thumbnail's opacity return to 60% when the mouse isn't over it.

    Step 14.
    Code Explanation:

    Line 24 - An onEnterFrame function is created which will execute any code inbetween the braces {} repedly, at the frame rate of the movie.

    Line 25 - This is the code used to move the "images" MC to the "target" value minus the images current Y position divided by the speed, whenever a thumb is pressed.

    Step 15.
    And here is the whole Actionscript.
     
    Step 16.
    And that brings us to end of this Flash tutorial to create a gallery. Download FLA (18-5-07)

    discuss this topic to forum

    relation tutorial

    No information

    Category

      3D (36)
      Math Physics (18)
      3rd Party (10)
      Navigation (70)
      Actionscripting (228)
      Optimization (17)
      Animation (166)
      Projector (11)
      Audio (54)
      Special Effects (170)
      Backend (26)
      Text Effects (92)
      Drawing (34)
      Tips and Techniques (58)
      Dynamic Content (38)
      Tricks (8)
      Games (114)
      Utilities (24)
      Getting Started (99)
      Video (59)
      Interactivity (48)
      Web Design (37)

    New

    Hot