AS3 MovieClip “enabled” property does not stop receiving events from mouseDown, mouseUp, keyDown, and keyUp etc… when set to false, only the movie clip’s Over, Down, and Up frames are disabled. You will need to set the condition within event handler to stop the event or disable the mouse event completely using “mouseEnabled” property from InteractiveObject class:
var enable:Boolean = true;
mc.buttonMode = true;
mc.addEventListener(MouseEvent.MOUSE_UP, function(event:MouseEvent) {
if (enable) {
enable = false;
event.target.enabled = false;
trace("This button is disabled!");
} else {
enable = true;
event.target.enabled = true;
trace("This button is enabled!");
}
});
or using “mouseEnabled” property:
mc.buttonMode = true;
mc.addEventListener(MouseEvent.MOUSE_UP, function(event:MouseEvent) {
event.target.mouseEnabled = false;
trace("This button is disabled completely!");
});
2 users commented in " AS3 MovieClip enabled property "
Follow-up comment rss or Leave a TrackbackWhat are a “movie clip’s Over, Down, and Up frames”?
When you have labels like “_up”, “_over”, “_down” on the layers, it will behave like button.
Leave A Reply