-
Call document class function from a movieclip on the timeline
Once again, I'm impressed with how obtuse everything must be.
I have a function defined in my document class that I want to call on a framescript of a movieclip placed on a timeline. Of course, left to itself it's "undefined", and I can't figure out how to reference parent/root/document class.
This should be a simple one for someone to help me with
-
If you have a document class why are you writing code on the timeline? You should possibly try to start writing seperate classes for your movieclips, as issues like this become simpler to solve.
but anyway, if the movieclip is directly placed on the stage you could try writing in the movieclips framecode: this.parent.myDocClassFunction();
as this.parent would be the stage which (I think) would link to your document class.
(I may be wrong, as I dont really use timeline code, but its worth a try)
-
Unfortunately that's one of the first things I tried, and that doesn't work. Thanks for the help though!
Any other ideas?
I'm writing frame code because I have created an animation in flash that I want to play out before the actual code kicks in. I pine for the simpler days of AS2.
As a side note, I tried dispatching an event at the frame, but that didn't work.
-
hmmm well you could controll it all from your document class (although this possibly an unnecessarily long way of solving your problem, but the only way i can currently think of).
so in the constructor of your doc class:
Code:
public function DocClass()
{
this.addEventListener(Event.ENTER_FRAME, testAnimationDone);
}
the instance name of the movieclip that you have placed on the stage in this example is called animatedClip.
Code:
private function testAnimationDone(e:Event)
{
if(this.animatedClip.currentFrame == this.animatedClip.totalFrames)
{
this.animatedClip.stop(); //stops your clip looping, you could put this in the last frame of animatedClip, but this way puts all code in the doc class
this.removeEventListener(Event.ENTER_FRAME, testAnimationDone);
myDocClassFunction(); //this is the function you have been trying to call
}
}
this method of doing thngs puts ALL your code in your document class, making it easiear to find later.
-
That's an interesting method! I'll check it out - thanks!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|