A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Move to a Frame after a set time?

  1. #1
    Member
    Join Date
    Nov 2006
    Posts
    93

    Move to a Frame after a set time?

    Hi.

    I'm having trouble moving to a different frame in my scene after a certain period of time. I want this to occur after several things have happened which are also time based.

    I tried this code:

    Code:
    		if (getTimer()-startTime>80000) {
    			stopAllSounds();
    			_root.gotoAndStop("gameFinishedEasy");
    		}
    This is put at the end of all the time events, but it does nothing...However if I change the amount of time to the same or under the last timed event it works, which I'm a little confused about. (I also tried putting it inside the onEnterFrame part where these clips are made to spawn at certain times, but this causes a stranger error where the last movie clip spawns frozen).

    So basically all these movie clips are spawned at different intervals, shortly after the final clip spawns I want to move to a different frame. At the moment all it lets me do is move to a different frame just before the last clip is spawned (at 78500).

    Any ideas what to do? Possibly a better piece of code? Perhaps put that code in a completely seperate object on the scene?

    Hope you can help, thanks.

  2. #2
    Member
    Join Date
    Nov 2006
    Posts
    93
    I made a seperate clip on frame 1 and put this code inside:

    Code:
    onClipEvent (load) {
    	trace("hello");
    	var startTime = getTimer();
    	if (getTimer()-startTime>1000) {
    		trace("bye");
    		stopAllSounds();
    		_root.gotoAndStop("gameFinishedEasy");
    	}
    The trace only produces the hello, not the bye and change frame.

    Whats the problem? =/
    Last edited by xtrava; 05-01-2007 at 08:03 AM.

  3. #3
    Hey Timmy!!! walsher's Avatar
    Join Date
    Jan 2005
    Location
    Latrobe, PA
    Posts
    1,899
    Howdy,

    You were really close on your second example. You just need to add another onClipEvent(enterFrame). Cause at the moment it will check that when the MC is loaded and only then.

    onClipEvent (load) {
    trace("hello");
    var startTime = getTimer();
    }
    onClipEvent (enterFrame) {
    if (getTimer()-startTime>1000) {
    trace("bye");
    stopAllSounds();
    _root.gotoAndStop("gameFinishedEasy");
    }
    }

    This way the timer gets added on every frame and can determine when the number are different.

  4. #4
    Member
    Join Date
    Nov 2006
    Posts
    93
    Ooooh...I see. I wondered why when I would trace the current timer it would only ever tell me one figure and then stop.

    Unfortunately, I've been working all day on getting it to work another way. I did by making a count of each clip being added to when they appear, then when the count gets to a certain amount it changes frame.

    This way works fine, its just a bit of a quick change rather than having a small pause which I originally wanted.

    I'm going to stick with this method though, as I've already published the file and am showing it to a lecturer tomorrow etc. If I get a chance before the coursework hand in I might change it.

    Thanks for the reply.

  5. #5
    Hey Timmy!!! walsher's Avatar
    Join Date
    Jan 2005
    Location
    Latrobe, PA
    Posts
    1,899
    Not a problem dude. Hope all goes well.

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