A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: Timeline navigation problem...

  1. #1
    Junior Member
    Join Date
    Jul 2009
    Posts
    15

    Timeline navigation problem...

    Hi

    I have a set of frames from frame 25 to 35

    Normally, I want the movie to play the tween that spans from 25 to 35, then stop UNLESS a button has been clicked back on frame 24 - then I want the tween played from 25 to 35 then jump to 46.

    Problem is, in the button function code, if I have...

    gotoAndPlay(25); gotoAndPlay(46);

    the timeline jumps straight to 46 - it doesn't play 25-35. Why?

    I tried putting a timer in between the two gotoAndPlays, but itignored that too and jumped to 46.

    So how do I tell it - 'play from 25-35 and stop, unless but_a was pressed back on Frame 24 - then play 25-35, and then play 46' ?

    Thanks for your time and info.

    Shaun

  2. #2
    Senior Member
    Join Date
    Mar 2003
    Location
    Canada
    Posts
    166
    3 ways of doing this:

    1) the easiest is to put the code into the timeline and check if clicked is true in the main class on frame 35 if it is then gotoAndPlay(35).

    2) use eventDispatcher in the timeline to talk to your main class. so on frame 35 write this:

    dispatchEvent(new Event("on35"));
    then in your main class add a listener when you initialize to say:

    addEventListener("on35",someFunction);
    private function someFunction(e:Event):void{
    removeEventListener("on35",gotoSplash);
    if(someAction == true){
    movieClip.gotoAndPlay(46)
    }
    }
    and on frame 35 just put:
    stop();

    3. Do an enterFrame event and check the currentFrame() == 35 and then do your check.

  3. #3
    Junior Member
    Join Date
    Jul 2009
    Posts
    15
    Thanks shamimsaad03

    Could I please trouble you for a little more help?

    I liked the first suggetion you made, but am unsure how to to check if a button was previously clicked.

    How would that fit into my code?

    Here is a shot of my timeline:



    Frame 24 code is at the end of this post, and frame 34 just has stop(); on it.

    I want the tween from 24 to 34 to play and stop, except if a button has been pressed anywhere from Frame 15-34 - in that case I want the tween to play from 24 to 34, and then ignore the stop (); on 34 and just goto and play frame 46.

    FRAME 24 code:

    stop();
    function NavCompany4(event:MouseEvent):void {
    trace("Nav "+arguments)

    switch(event.target.name){

    case "company_but_4":

    play();

    }
    }

    company_but_4.addEventListener(MouseEvent.CLICK,Na vCompany4);

    Thanks for your time and help.

    Shaun

  4. #4
    Senior Member
    Join Date
    Mar 2003
    Location
    Canada
    Posts
    166
    where are you storing your variable that says clicked, are you programming everything on a timeline or do you have a class?

  5. #5
    Junior Member
    Join Date
    Jul 2009
    Posts
    15
    It's all timeline programming

  6. #6
    Senior Member
    Join Date
    Mar 2003
    Location
    Canada
    Posts
    166
    :P Not the best idea, but you can do this

    on

    15-34

    someButton.addEventListener(MouseEvent.CLICK,someF unction);

    function someFunction(e:MouseEvent){
    var clicked:Boolean = true;
    }
    then on 34;

    if(clicked){
    play();
    }else{
    stop();
    }

  7. #7
    Junior Member
    Join Date
    Jul 2009
    Posts
    15
    Thanks shamimsaad03

    I tried that, but I get an 'access of undefined property clicked' error.

    It's as if it's not recognizing the var clicked because it's in a previous keyframe. Should this be the case? I thought once a var was claimed, you could call it in future keyframes as long as they're on the same timeline.

    Cheers

    Shaun

  8. #8
    Senior Member
    Join Date
    Mar 2003
    Location
    Canada
    Posts
    166
    its not registering your MC that you might be accessing, make sure all your MC are initialized on first frame, or just create a new sprite dynamically

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