A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: How do I script a back button from the main timeline to a movie clip?

  1. #1
    Member
    Join Date
    May 2004
    Posts
    71

    How do I script a back button from the main timeline to a movie clip?

    Movie clip plays, when it reaches the end there is a stop action. Two buttons are displayed, each one takes you to a different page (in the main timeline, have on(release) _root.gotoAndStop for the buttons)..

    On the two pages that the buttons take you to (on the main timeline) I want to put a back button on each to take you back to the movie clip and tell it to go to the last frame of the movie clip and stop. I'm pretty sure I know how to do that, but the problem is I have more than one movie clip: how do I script the back button to send you back to the last movieclip you viewed?

  2. #2
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    _root.movieClipName.gotoAndPlay(framelable);

  3. #3
    Member
    Join Date
    May 2004
    Posts
    71
    That is going to take me from the movie clip to the main (root) sage. I need a button that will take me from the main stage back to the previously viewed movie clip. Is there a return-to-last-upload script in regards to movie clips? I want to make a back button to put you from the main stage frame into the last movie clip you viewed.. how would I go about doing that?

  4. #4
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    that IS how you would do that.....unless your content is no longer on the stage..or needs to be re-loaded....

    but if you want to go back to the movie clip on stage..and show a particular "frame" thats how you do it..have you even tried?

    unless I am missing what yoru asking..

  5. #5
    Member
    Join Date
    May 2004
    Posts
    71
    Yeah, that's basically it. I need a back button that will take you back to the previously viewed (last loaded) movie clip. If somebody could figure out how to script that I'd greatly appreciate it. (Maybe something with _root, then target-path.. I'm not sure)

  6. #6
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    what you'll have to do is assign a certain frame label to a variable... and have that on a frame action (or however you wanna mark/anchor your "back button" to)

    when you play yoru movie mentioned above..and you "stop" on yoru last frame..with your two button choices.. have a frame action similar to

    anchorFrame= _root.mcName.gotoAndPlay(15);


    then on you back button..have something like:

    onPress
    gotoAndPlay(anchorFrame);

    I havent read up to much on the actual "anchor" actions/labels in MX...you shoudl check those out..may be similar to do what you want..


    my syntax is wrong..as Im at work...and I have even tried it yet..but you can get an idea of how to mark/anchor your frames..and use one back button....each time you wanna "anchor" something..you just change the value of "anchorFrame"

  7. #7
    Member
    Join Date
    May 2004
    Posts
    71
    Yeah, I can look it up.. I just needed someone to point me in the right direction.. thanks a lot for doing so.

    One question though (that you may or may not be able to answer.. not sure how much you know about anchor frames) There are six movie clips that are the same as the above described. If they all end on a frame labeled "anchor frame'' will the back button spit you back onto the last loaded (viewed) movie clip, or would it get confused?

    (Thus the problem, I know how to script separate back buttons for each movie clip, but I want to just have one universal one to take you back to the previously viewed mc).. I'll check out the anchor frames, read up on that and see if I can get it to work. thanks

  8. #8
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    if you want to use one "back button" for all your anchors.. you will have to do as I outlined above.

    when you have a frame you want to make an "anchor" have a frame action that sets the value of a variable called "anchorFrame"

    example: if you have 3 movie clips on your stage... all 3 of them in the last frame of whatever frame it is you want to be an "anchor".. you will have your code.

    have a frame action that sets a variable for the clip to be focused on..and make a variable for the frame

    _root.anchorClip = _root.clip1;
    _root.anchorFrame = 22;

    then on your button have something liek:
    on (release) {
    _root.anchorClip.gotoAndPlay(_root.anchorFrame);
    }

    you will have to make sure your "clips" are on the stage...though..or move the playhead to where that are.

    here is a quick .fla I made...you'll have to adapt how it realtes to YORU movie..but all the code is the same.. maye a few "frame" tweaks....
    Attached Files Attached Files

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