MouseEvent listener is registered with container, with capture set to true.
The click handler is called when the area over a cube is clicked.
instance names used in this code:
container, child1, child2, child3, cube, image
BTW, nothing but child MovieClips should be inside the container movieclip(!)
That means nothing
whatsoever; no bitmaps, static text or decorative graphics. zip. zilch. nada.
Additionally, the instance names must all
exactly match those used in the code, and each child must contain a cube and an image. Otherwise, this code will throw an error.
ActionScript Code:
import flash.display.MovieClip;
import flash.events.MouseEvent;
var num:int = container.numChildren;
for(var i:int = 0; i < num; i++)
{
var child:MovieClip = container.getChildAt(i) as MovieClip;
child.mouseEnabled = false;
child.image.mouseEnabled = false;
child.cube.buttonMode = true;
}
container.addEventListener(MouseEvent.CLICK, onClick, true);
function onClick(e:MouseEvent):void
{
trace("clicked " + e.target.parent.name + "." + e.target.name);
}