A Flash Developer Resource Site

+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Junior Member
    Join Date
    Feb 2010
    Posts
    2

    timeout + go to a different frame

    Hi Guys, first post here, I have tried to search but it is always quite difficult. Sorry for troubling you with simple questions!

    I am designing something that has a front page, then a menu and then individual pages. These pages are all static (apart from a couple having a moving graphic)

    What I want to do is if you get to one of the individual pages, after a certain amount of time (maybe 3 minutes) it goes back to the front page.

    Is there an actionscript command that you can use for this? Or do you have to do it with a number of frames so it "plays" the static page for a while then moves on. *note* I don't want it to move to the next page, I want it to go back to the front page.

    Thank you very much for any help!

  2. #2
    Junior Member
    Join Date
    Feb 2010
    Posts
    23
    you can user a Timer. once you get to the page that you want to be redirected from after a certain amount of time set the Timer, add a TimerEvent.TIMER_COMPLETE event listener to it (and start the timer - i have forgotten that once or twice) and tell the handling function to gotoAndPlay(1);

  3. #3
    Junior Member
    Join Date
    Feb 2010
    Posts
    2
    Hi this thread has really helped but I am having a problem.

    I made a timer to go back to frame 1 after a certain amount of time (ie there is 'next' and 'prev' buttons, so if nothing is pressed. This timeout works.

    My problem is that even if the next frame is gone to, the timeout timer keeps going and goes back to frame1.

    All my frames start with
    ------------
    stop();
    ------------
    Here is my timer code

    // Reset Timer
    var timeoutTimer:Timer = new Timer(5000, 1); // 5 second timeout
    timeoutTimer.addEventListener(TimerEvent.TIMER, reset);
    timeoutTimer.start();

    function reset(event:TimerEvent):void
    {
    gotoAndStop(1);
    }
    ------------------------------------------

    How can I make the timer stop when a different frame is selected (and start the timer actually, but Im pretty sure timeoutTimer.start(); will suffice.

    thanks for any help!

  4. #4
    Junior Member
    Join Date
    Feb 2010
    Posts
    23
    hey. you're right timeoutTimer.start(); will make it start again, on the line where you you have:

    function reset(event:TimerEvent):void
    {
    gotoAndStop(1);
    }

    instead make it:

    function reset(event:TimerEvent):void
    {
    gotoAndStop(1);
    timeoutTimer.stop();
    }

    that'll stop the timer and when you get to the page that originally had the timer on it will start again.

    that help?

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