1
votes

I just found a way to do it, but I'm still getting an error.

On the main timeline I have:

var onBeat:Boolean = new Boolean;

and inside a movieclip I attempt to access it with:

MovieClip(root).onBeat = true;

and it technically works, the variable changes. But it throws this error which causes problems:

Error #1034: Type Coercion failed: cannot convert flash.display::Stage@7fffaa2c0d1 to flash.display.MovieClip.

Is this just an impossible task?

1
What is root? How do you define it? Where do you define it?user2655904
I thought root was just referring to the highest level parent. The mainstage in this case. Should I be defining it somewhere?Galbert
How to add your "inside MovieClip"? this.stage.addChild(insideMc); or this.addChild(insideMc); ?Yasuyuki Uno
The problem is that root is the stage (a Stage class) and you try to cast it to a MovieClip. SHouldnt it be just root.onBeat = true; ?Philarmon

1 Answers

0
votes

You got that error because you've added your MovieClip to the stage's display list and not to the main timeline one.

So in your main timeline code (or your document class), you can add your MovieClip using addChild(your_mc_instance) or this.addChild(your_mc_instance).

But you can also get a working code even with your MovieClip instance added to the stage using, for example :

var _root:DisplayObjectContainer = DisplayObjectContainer(root);
MovieClip(_root.getChildAt(0)).onBeat = true;

_root.getChildAt(0) here is returning your main timeline instance as it has also been added to the stage's display list before any other object.

Hope that can help.