Steven Mercatante
Steven Mercatante

Reputation: 25295

How do I access a MovieClip on the stage from the Document Class?

I have a "box_mc" movieclip on the root of my stage and I need to select it from within my Document Class. I thought Stage.getChildByName("box_mc") would work, but it just returns null. Thanks in advance.

Upvotes: 0

Views: 1053

Answers (2)

Myk
Myk

Reputation: 6215

Well, assuming you're automatically declaring stage references (on by default, so unless you turned this off you're fine) then all you have to do is type box_mc.

In your document class constructor just type trace(box_mc) and it should work.

Upvotes: 0

Allan
Allan

Reputation: 3314

in your document class, in the constructor add

addEventListener(Event.ADDED_TO_STAGE, init, false, 0, true);

then in the function init:

private function init(e:Event):void
{

    getChildByName("box_mc") 

}

Upvotes: 3

Related Questions