Skip to main content
miquael
Inspiring
January 24, 2009
Answered

stop main timeline in AS3

  • January 24, 2009
  • 7 replies
  • 5536 views
I searched the forum and perhaps found some relevant solutions, yet I still don't get it. How do I make simple "stop()", "play()", and check "currentFrame" on the main timeline from an AS3 Class file?

I have an older AS2 Flash timeline animation that I'm converting to AS3, and also importing an AS3 swf into.

Everything works fine, except I had to remove the "stop()" on the main timeline (so the animation does not loop), and trying to do that from the document main .as file.

I get an error when trying to access "currentFrame" of the stage.

HOW DO I PUT A "STOP" ON THE MAIN TIMELINE?

- - - -

This topic has been closed for replies.
Correct answer kglad
if Banner is your document class that means your main timeline must have only 1 frame (because Banner extends Sprite) and that means it makes no sense to check for currentFrame and it makes no sense to goto any frame.

do you know what you're doing picking the Sprite class or do you really want Banner to extend the MovieClip class?

7 replies

kglad
Community Expert
Community Expert
January 26, 2009
cast all your references to this.root as a movieclip like i showed in my above message.
miquael
miquaelAuthor
Inspiring
January 26, 2009
I'm still not understanding. How do I refer to the primary document Class with a MovieClip?

I have made this attempt (and get a "TypeError: Error #1006: value is not a function" error):


kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
January 26, 2009
if Banner is your document class that means your main timeline must have only 1 frame (because Banner extends Sprite) and that means it makes no sense to check for currentFrame and it makes no sense to goto any frame.

do you know what you're doing picking the Sprite class or do you really want Banner to extend the MovieClip class?
miquael
miquaelAuthor
Inspiring
January 25, 2009
Hmmm. Sorry, I'm still coming up to full speed with AS3 practices.

Yes, Banner is the document class. What do you mean by copy and paste using the attach code option? The coe is already in Bannas.as. What/where is the attach code option?
miquael
miquaelAuthor
Inspiring
January 25, 2009
I tried this also (does not work):


kglad
Community Expert
Community Expert
January 25, 2009
if Banner is your document class, copy and paste your corrected code using the attach code option
miquael
miquaelAuthor
Inspiring
January 25, 2009
Banner is the primary AS file for the FLA. Is this the same as calling a class instance?
kglad
Community Expert
Community Expert
January 25, 2009
your banner instance needs to be in the displaylist.
miquael
miquaelAuthor
Inspiring
January 25, 2009
Hey kglad, thanks for the insight ...

Hmmm ... I'm not sure what this is really attempting to do ...

And it generates this error:

"TypeError: Error #1034: Type Coercion failed: cannot convert Banner@396aaba1 to flash.display.MovieClip.at Banner/update()"

Can you explain more how this should resolve it?
kglad
Community Expert
Community Expert
January 24, 2009
use the root property of your Banner and cast it as a movieclip:

if (MovieClip(this.root).currentFrame > 150) {
MovieClip(this.root).gotoAndStop(150);
}