jeremiemv
jeremiemv

Reputation: 138

Disabling/re-enabling interactivity

As an AS3 beginner, I'm trying to translate an old AS2 trick into AS3. I want to disable then re-enable any kind of interactivity with all the display objects on the stage, at once. For example while waiting for external assets to load or after a user clicks on a menu item.

This what I used to do with AS2 :

protect_mc.onRelease = function():Void  {};
protect_mc.enabled = false;
protect_mc._alpha = 0;
protect_mc._visible = false;

Then switching protect_mc._visible to true or false.
(protect_mc being an empty movie clip with the stage's height and width, at the highest depth)

My first idea is registering a listener with the Stage for the capture phase of MouseEvent.CLICK that stops all input events propagation (mouse, focus, text...), when a "lock" static variable is set to true or does nothing otherwise.

Second idea is using a Custom Event...

Any advice would be greatly appreciated :)
Thanks.

Upvotes: 0

Views: 134

Answers (2)

dx0ne
dx0ne

Reputation: 11

if you don't have any listeners attached directly to stage you can also use:

stage.mouseChildren = false;

Upvotes: 1

Maxim Kachurovskiy
Maxim Kachurovskiy

Reputation: 3022

The following code disables all interaction with display object and it's children:

movieClip1.mouseChildren = false;
movieClip1.mouseEnabled = false;

Upvotes: 1

Related Questions