Skip navigation
Currently Being Moderated

Actionscript 2 for flash button components

Mar 27, 2012 8:20 AM

Tags: #flash #buttons #as2

Hi,

 

Feel really dumb here but I recently purchased a mac computer (used) that had Flash professional cs3 installed and so I thought I would give it a go seeing as I have been using Director for sometime.  I seem to be having quite the struggle scripting the buttons in my project. here is what I have and what I would like to accomplish. It is rather simple:

 

I have a movie that is 30 frames long.

I have 6 buttons on the first frame that will take the viewer to 6 different frames in the movie.

The buttons were pulled from the components window. 

 

Here is what I want to do:

 

I want to click on button 1 throughout the movie and have it take me to frame 5

I want to click on button 2 throughout the movie and have it take me to frame 10

I want to click on button 3 throughout the movie and have it take me to frame 15

I want to click on button 4 throughout the movie and have it take me to frame 20

I want to click on button 5 throughout the movie and have it take me to frame 25

I want to click on button 6 throughout the movie and have it take me to frame 1 (main menu)

 

Seems simple enough, but when I drag the button from the components window onto the stage, I dont know where to get the script from? When I go to the library and insert the GoToandStop script, it doesnt work.

 

Lingo is different then actionscripting and so I dont understand it.

 

Can someone offer some insight/advise with the scripting of the component buttons?

 

Thanks

 
Replies
  • kglad
    72,235 posts
    Jul 21, 2002
    Currently Being Moderated
    Mar 27, 2012 10:24 AM   in reply to Design4u1

    first click each button to select it and then in the properties panel (window/properties), assign an instance name (eg, btn1, btn2 etc) for your buttons.

     

    then open the actions panel (window/actions) with nothing on-stage selected enter:

     

    for(var i:Number=1;i<=6;i++){

    this["btn"+i].ivar=i;

    this["btn"+i].onRelease=function(){

    if(this.ivar==6){

    gotoAndStop(1);

    } else {

    gotoAndStop(this.ivar*5);

    }

    }

    }

     
    |
    Mark as:
  • kglad
    72,235 posts
    Jul 21, 2002
    Currently Being Moderated
    Mar 27, 2012 1:48 PM   in reply to Design4u1

    you can use the code snippets panel (window/code snippets)

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points