PDA

View Full Version : ENTER_FRAME issue



atjkan
May 30th, 2008, 10:44 AM
Hi guys, I'm really quite new to actionscript let alone AS3, hopefully you can help me out with an issue I'm having.

I have a movieclip with instance name "Title" within my main timeline. I want to jump to a frame within "Title" labelled "Appear" whenever the playhead reaches a certain frame on the main timeline.

In AS2 I would have gone with onEnterFrame, but I'm not sure what to do with AS3. Here's what I've attempted, but it doesn't seem to work:



addEventListener(Event.ENTER_FRAME,myFunction);
function myFunction(event:Event) {
trace("MovieClip(root).Title.gotoAndPlay(Appear)");
}
removeEventListener(Event.ENTER_FRAME,myFunction);


Any help you could give would be great.

Thanks!

Digitalosophy
May 30th, 2008, 11:03 AM
Just stick the removeEnterFrameListener inside your function



addEventListener (Event.ENTER_FRAME,myFunction);
function myFunction (event:Event) {
trace ("MovieClip(root).Title.gotoAndPlay(Appear)");
removeEventListener (Event.ENTER_FRAME,myFunction);
}

atjkan
May 30th, 2008, 11:17 AM
Thanks for the suggestion, still not seeing anything happening. Does the removeEventListener stop the movieclip playing?

senocular
May 30th, 2008, 11:19 AM
Why is the enterFrame event needed? By the description it sounds like you just need a goto command in a location in the main timeline

Digitalosophy
May 30th, 2008, 11:19 AM
The removeEventListener will just stop calling the function. I just tested it briefly, I just added that code to the first frame of my time line and "MovieClip(root).Title.gotoAndPlay(Appear)" traced once.

You have a small demo I can see?

edit: that's true sen..

atjkan
May 30th, 2008, 11:25 AM
Ah you're so right! Thanks that makes life a whole lot simpler! That's it working now.

:)

senocular
May 30th, 2008, 11:52 AM
http://www.senocular.com/smilies/jobwelldone.gif