Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0

Reply
 
Thread Tools Rate Thread Display Modes
Old 06-17-2012, 11:52 PM   #1
chiapa
Registered User
 
Join Date: Jun 2012
Posts: 9
Default Manipulating frames in the timeline

Hi everyone,

I've got a first frame in the timeline in which the stage has a play button that, when pressed, advances the timeline to the next frame, where the game should actually start, with UFO's and stuff flying through the stage. But I want the "action" to start only in the second frame of the timeline. I tried this, it doesn't work: the UFO's don't appear in the first frame but don't appear in the second either, as I wanted.

function Main():void
{
if (currentFrame == 2) //it's wrong, I was just trying...
{
Mouse.hide();
stage.addEventListener(MouseEvent.MOUSE_MOVE,mexe_ mira);
...
...
...
...
}
}

If I don't put the "if", in the first frame (with the play button) all the UFO's appear, flying across the stage. They aren't supposed to.
If I put the "if", there are no UFO's at all, in any frame.

Any ideas? Thanks
Chiapa
chiapa is offline   Reply With Quote
Old 06-18-2012, 12:51 AM   #2
USAFDrew2011
Flash_Developer
 
Join Date: Jul 2011
Location: Layton City, Utah
Posts: 178
Default

Can you post your fla file?
USAFDrew2011 is offline   Reply With Quote
Old 06-18-2012, 02:00 AM   #3
-:)lauri
Senior Member
 
Join Date: Aug 2008
Location: Helsinki, Finland
Posts: 1,135
Default

if you must put things in main timeline instead of putting them in separate MovieClips between which just change visibility status etc, something like this might work:

This starts checking what is the current frame and if it is 2 then it marks game started and calls the Main() function

ActionScript Code:
import flash.events.Event; import flash.events.MouseEvent; import flash.ui.Mouse; var startFrame:Boolean = false; addEventListener(Event.ENTER_FRAME, onEnterframe); function onEnterframe(event:Event):void {     if(!startFrame && currentFrame == 2)     {         startFrame = true;         Main();     } } function Main():void {     // now it is frame 2     Mouse.hide();     stage.addEventListener(MouseEvent.MOUSE_MOVE,mexe_mira);     //...     //...     //...     //... }
-:)lauri is online now   Reply With Quote
Old 06-18-2012, 02:32 PM   #4
henke37
Senior Member
 
henke37's Avatar
 
Join Date: Mar 2009
Location: Sweden
Posts: 9,784
Send a message via Skype™ to henke37
Default

Have you considered putting the code in a place that isn't the constructor? Like say, a different method?
__________________
Signature: I wrote a pair of articles about the timeline.
henke37 is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:29 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.