A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: help required, pls

  1. #1
    Member
    Join Date
    Sep 2003
    Posts
    34

    help required, pls

    i have given this action code to a button

    on (release) {
    _root.cb == 21;
    gotoAndPlay("Scene 2", 100);
    }

    i want it to go to frame hundred, which it does, and assign the variable cb the value of 22. i dont know if it does this or not cos i dunno how to check that.

    later on on frame hundred i have this action code:

    if(_root.cb==21){
    _root.gotoAndStop("Scene 3", 1)
    }else if(_root.cb==22){
    _root.gotoAndStop("Scene 4", 1)
    }

    i have more buttons like the one shown above, and each gives the variable cb a different value. i want frame hundred to make the movie jump to the correct scene and frame according to what value the variable cb has.

    also as i am new to actionscript, i dunno if i have to declare the variable cb with the var fucntion. if so where do i do it. i am not sure why i put in the _root bit before the name cb, i jus did this becos someone told me to do so....

  2. #2
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    Set your "cb" variable on the first frame of your movie, using _root or _level0 likewise...

    _level0.cb = 0;

    From here on you will allways refer to your variable as "_level0.cb" and not "cb" alone. If you want to set a value to it (from anywhere), just use 1 "=" as...

    _level0.cb = 21;

    In an if statement you would use 2 "==".

    So your button's script should look like this...
    code:

    on (release) {
    _level0.cb == 21;
    //gotoAndPlay("Scene 2", 100);
    _root.gotoAndStop("frame100");
    }



    Notice that in the above I changed your gotoAndPlay to a gotoAndStop and that I'm targeting a frame label "frame100" rather than a scene name & a frame number. I have, of course, labeled frame 100 of scene 2 with the label "frame100", without the doubles quotes when labeling the frame itself.

    Check my last post in this thread, to understand why I'm doing that...
    http://www.flashkit.com/board/showth...hreadid=508210

    Now on frame 100 of scene 2, your script should somewhat look like this...
    code:

    stop();
    if(_level0.cb == 21){
    //_root.gotoAndStop("Scene 3", 1)
    //Again use a frame label...
    _root.gotoAndStop("sc3fr1");
    }else if(_level0.cb == 22){
    //_root.gotoAndStop("Scene 4", 1)
    //Again use a frame label...
    _root.gotoAndStop("sc4fr1");
    }



    Of course the first frames of scene 3 & 4 would have to been labeled sc3fr1 & sc4fr1 - Without doubles quotes when labeling the frames themselves.

    Hope this somewhat clears it up.

  3. #3
    Member
    Join Date
    Sep 2003
    Posts
    34
    thanks the code works
    except i had to remove the stop bit u put in and chnage the gotoandstop to gotoandplay
    Last edited by mo_themaster; 11-15-2003 at 06:29 PM.

  4. #4
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    Not much excitement is there?

    Are you sure I should have answered you?

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