It seems like a simple problem access root

I have a mc1 and menu (movie clips) on the stage and inside mc1 I i have the following code
button.addEventListener(MouseEvent.CLICK,function(){menu.visible=false});

so it should turn off the menu… but its giving me

1120: Access of undefined property menu.

I also tried root.menu.visible = false; is there a way to access a movie clip thats on the root … through a script inside a mc … its seems like ive done this already with as3 before

But mostly i do everyone on one frame this time i didnt…

use

Object(root).menu

By casting it to Object, you’re avoiding the type checking that would otherwise be made on the root property which is, by default, typed as DisplayObject. That typing is what allows Flash to check to make sure you’re using the property right. If you try to access a property not defined in that type, like menu (the menu property is not defined in DisplayObject) Flash will throw an error. The problem is, your root really is more than a DisplayObject and has those extra properties. So to allow for those to be recognized, you must ditch the DisplayObject-only association. The easiest way is to cast to Object, but the “better” way would be to cast it to the actual class type of your root.

Thanks
I appreciate the explanation :slight_smile:
Take care