Learn Flash: Array

Home Food Mates • Members Tutorials Forum Buy Templates Contact Us 

 


Flash Tutorials

   

Flash Tutorial - Intro to Arrays

 

Free Flash Tutorial


Example A    <<   Previous      Intro   A   B   C   D     Next   >>       >>   Webwasp Mates

 

Arrays: Example A

In the example below, each button calls a different listing from the Array.

Example: Download the Flash file  Int 128a


Simple example of using an Array.

Example A - Step One: Building the Movie

  1. Open a new: Flash Movie
  2. Set the Movie size to: 200 x 130
  3. Select the Text Tool:
  4. Drag out a text box on stage: Text Box
  5. If the Property Inspector is closed, open it: Window > Properties (Ctrl F3)
  6. In the Property Inspector select: Dynamic Text


    Selecting Dynamic Text.

  7. Give the Text Box a Variable Name (Var): myText


    Your Property Inspector should look similar to this.
  8. Note: Don't mix up the Instance Name and Variable name (Var).

  9. Type inside the text box something like this: Click one of the buttons to update the text.
  10. Go back to using the standard Selection Tool:
  11. Create or place three buttons along the bottom of the Movie. I used the Oval buttons that are in the Common Library: Window > Other panels > Common Libraries > Buttons

    Note: Do not use Components, Knobs or Faders from the Common Library as they function differently.


Your Movie  should look similar to this.

You have completed building the Movie and are now ready to create the ActionScript for the Array.


Example A - Step Two: Building the Array

  1. In the Timeline click on: Frame 1
  2. If the Action Box is closed, open it: Window > Actions (F9)
  3. Place the following ActionScript:

    var myArray = new Array();
    myArray[0] = "You can have text or a number here or anything you like really!";
    myArray[1] = "More text here.";
    myArray[2] = "A number here: 123";
    myArray[3] = "Other stuff";


    You can see that this sets up a standard Array called: myArray. There are four listings in total.


Example A - Step Three: The Button ActionScript

  1. Select the blue button on the left: Blue Button
  2. Attach the following ActionScript to the button (skip the gray comments if you wish):

    //  On release of the Mouse button do...
    on
    (release){
        
    //  My Text is the same as the first listing in the Array
        myText=myArray[0];
    }


    You can see that the ActionScript is very simple.
  3. For the subsequent buttons simply repeat the same ActionScript but change the Array number each time. Like this:

    on (release){
        myText=myArray[
    1];
    }

         

Example A    <<   Previous      Intro   A   B   C   D     Next   >>       >>   Webwasp Mates


Webwasp Community: Webwasp Mates & Dates

Why not try out webwasp's new community. Meet new people, find friends in your area: Webwasp Mates & Dates

 Top of Page Home Food Mates Members Tutorials Forum Buy Templates Contact Us 
 All material on this site is protected under international copyright © law. DO NOT reproduce any material from this site without written permission. Please ask as permission is often granted.