A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: [RESOLVED] Need help with AS2 button and variable

  1. #1
    Senior Member
    Join Date
    Mar 2008
    Posts
    168

    resolved [RESOLVED] Need help with AS2 button and variable

    I have a button called "btn01" on main timeline with the following actionscript;

    btn01.onRelease = function() {_root.map_mc.gotoAndStop("map01");}

    I also have a map on the maintimeline with 50 state buttons with the following actionscript;

    on (release) {
    _root.gotoAndPlay(3);
    _root.mc_allstates.gotoAndStop("Washington");
    _root.state_no=0;
    A_fg_allstates.gotoAndStop("Washington");
    state_now="Washington"
    trace (state_now);

    }



    I have a declared variable "state_now" that gets updated when the above buttons are clicked with current State Name. I have traced it and it is working.

    On the main timeline is a MC "A_fg_allstates" with 50 key frames labeled all 50 of the US states. What I need is to get btn01 to advance to the labeled frame in A_fg_allstates using the variable populated by clicking the state button above.

    Hope that makes sence, basically how do I use a variable to define the labeled frame in a MC to advance to on click.

  2. #2
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,
    PHP Code:
    on (release) {
    _root.gotoAndStop(state_now);

    without seeing it that is

  3. #3
    Senior Member
    Join Date
    Mar 2008
    Posts
    168

    Not sure how this gets coded but here is what I am thinking;

    Code:
    btn01.onRelease = function() {
    _root.map_mc.gotoAndStop("map01");
    A-fg_allstates.gotoAndPlay("state_now");
    
    
    
    
    
    }

  4. #4
    Senior Member
    Join Date
    Mar 2008
    Posts
    168
    Hey Fruitbeard gald you are online hope life is good buddy

  5. #5
    Senior Member
    Join Date
    Mar 2008
    Posts
    168
    so when using a variable as above the proper syntax is without parenthesis?

    A-fg_allstates.gotoAndPlay(state_now);

    NOT

    A-fg_allstates.gotoAndPlay("state_now");

    Sorry first time I have ever used variable in defining button click actions

  6. #6
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    yes, inside of "" makes it a name, if you follow.

  7. #7
    Senior Member
    Join Date
    Mar 2008
    Posts
    168
    does the same sytax rule apply to assiging a value to the variable on click ie

    state_now="Alaska"

    or
    state_now=Alaska

  8. #8
    Senior Member
    Join Date
    Mar 2008
    Posts
    168
    sorry but this scope issue has me really stumped. What version of Flash are you using? Would like to send you the complete file but in 5.5 is 10mg and 4.0 its 20 mg

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center