A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: variables and movieclips

  1. #1
    Junior Member
    Join Date
    Apr 2001
    Posts
    11
    I have several buttons which instruct a movie clip to play.

    When the clip has finished, I want it to goto one of several scenes in the main movie. Which scene depends upon which button was hit.

    I thought I could do this by sending a variable from the button to the movie clip. What is the correct way to set a variable in the movie clip in this way.

    The second problem is getting the movie clip to relate back to the main movie. I can't get it to move to another scene even by putting:
    gotoAndPlay ("Scene 2", 1);
    or
    gotoAndPlay ("_root.Scene 2", 1);

    My guess is with both issues I'm overlooking something basic in addressing paths. What is it?

  2. #2

    Try this

    Try this:

    in the first frame of your _root timeline, set a variable SCENE (ie: scene = "".

    On the button(s), make an action like this:

    on (release) {
    _root.scene = "nameOfTheSceneThisButtonRelatesTo";
    movieclip.gotoAndPlay(1);
    }

    In the movieclip's last frame:

    nextScene = _root.scene;
    _root.gotoAndPlay(nextScene);

    This should work.

  3. #3
    Junior Member
    Join Date
    Apr 2001
    Posts
    11

    Re: Try this

    Thanks
    I agree - it looks like it should work, but it doesn't for me. The movie clip plays and I'm back at the beginning of scene 1.



  4. #4
    Senior Member
    Join Date
    Aug 2000
    Posts
    2,235

    Re: Re: Try this

    Label the frames in question and on the button put;

    next="labelname";

    In the last frame of the clip put:

    _root.gotoAndPlay(_root.next);

    To target the root:

    _root.gotoAndPlay("labelname")

    You must label the frame to target the root from a clip.

    ~mgb
    [Edited by mgb on 05-18-2001 at 09:16 PM]

  5. #5
    Senior Member
    Join Date
    Aug 2000
    Posts
    588
    Along with label names, you can also use frame numbers, if you add up all of the frames in the scenes previous. So if scene 1 has 100 frames and you want to target scene 2, frame 1, use frame 101 as your target frame.

    mgb's way is probably a little easier...but just another option for you.

  6. #6
    Junior Member
    Join Date
    Apr 2001
    Posts
    11

    Smile Re: Re: Re: Try this

    Thankyou thankyou thankyou all!

    This worked! Brilliant!


    Originally posted by mgb
    Label the frames in question and on the button put;

    next="labelname";

    In the last frame of the clip put:

    _root.gotoAndPlay(_root.next);

    To target the root:

    _root.gotoAndPlay("labelname")

    You must label the frame to target the root from a clip.

    ~mgb
    [Edited by mgb on 05-18-2001 at 09:16 PM]

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