Flash Video Player

ADDED_TO_STAGE event

by admin on October 4, 2007 · 0 comments

in Flash CS3, Sintax, Tutorials

Here we are again with a new trick of the day (even though I do not consider it as a trick but pure extract of OOP). This one could help us more then once when developing application with Flash CS3.
I am talking about the event Event.ADDED_TO_STAGE.

We need a good example to arrive to the point of this tutorial.
Let us suppose that we have a MovieClip on stage named ‘container_mc’ and a second MovieClip named ‘quadrato_mc’.
We would like to attach another MovieClip placed in library (associated to a class named ‘clip’) inside container_mc. Up till there everything is fine as we know more then once how to do it: take a look at this article to refresh your memory if needed.

My question to you at this point, would be:
do we need to create the class associated to the MovieClip that we want to attach o shall we let Flash do the job for us to create it?

Personally, I do think that we should always create it our self.
First of all, doing so, we do not need to write codes inside the MovieClip as we would write everything in the class keeping full control and keep away from unwanted errors.
The second point is that we can maintain the whole hierarchical tree of our application.
I explain myself better:
And if we wanted to retrieve quadrato_mc placed on stage from the attached clip that is found inside container_mc?
We know that the famous _root does not exist anymore and up till now we have used the technique to pass the value of the stage from the Document Class implementing the building function, from the class associated to the attached MovieClip, a receiving parameter inserted in a property.

It is not easy to explain it by words so let us see a concrete example…

Read more

Share This Post

Related posts

{ 0 comments… add one now }

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="">

Older post: Newsletter module

Newer post: Operator is