I’m trying to put objects inside a movie clip that will be masked
allowing the user to scroll through them
My current solution is to add en event listner for each of the
internal movie clips…
outer_mc.myObject1.addEventListener(MouseEvent.MOUSE_DOWN, swapMovie);
outer_mc.myObject2.addEventListener(MouseEvent.MOUSE_DOWN, swapMovie);
outer_mc.myObject3.addEventListener(MouseEvent.MOUSE_DOWN, swapMovie);
outer_mc.myObject4.addEventListener(MouseEvent.MOUSE_DOWN, swapMovie);
outer_mc.myObject5.addEventListener(MouseEvent.MOUSE_DOWN, swapMovie);
outer_mc.myObject6.addEventListener(MouseEvent.MOUSE_DOWN, swapMovie);
outer_mc.myObject7.addEventListener(MouseEvent.MOUSE_DOWN, swapMovie);
outer_mc.myObject8.addEventListener(MouseEvent.MOUSE_DOWN, swapMovie);
outer_mc.myObject9.addEventListener(MouseEvent.MOUSE_DOWN, swapMovie);
outer_mc.myObject10.addEventListener(MouseEvent.MOUSE_DOWN, swapMovie);
outer_mc.myObject11.addEventListener(MouseEvent.MOUSE_DOWN, swapMovie);
outer_mc.myObject12.addEventListener(MouseEvent.MOUSE_DOWN, swapMovie);
function swapMovie(e:MouseEvent) {
trace(e.currentTarget.name + " selected");
}
Since there can be a variable list of internal movie clips this can get
unruley (and ugly 🙂 so I’m trying to add a listener for the parent object
This is the current attempt…
outer_mc.addEventListener(MouseEvent.MOUSE_DOWN, swapMovie);
function swapMovie(e:MouseEvent) {
trace(e.currentTarget.name + " selected");
}
however this just returns “outer_mc” and using target instead of currentTarget
returns the random instance number Flash assigns instance128, instance 23, etc.
Does anyone have a solution that will get the instance name of the child object
that will work in actionscript 3? I’ve looked and the closest thing is using the
target solution which doesn’t return the actual instance name.
You can try to do something like that :
Basically what that does is goes up one level until it founds the outer_mc, then stop, and return its clicked children.