AS#3 target ignoring parent movieClip

Go To


I changed the question as its seems to be a problem with target not registering children mc/ or nested MovieClips.

    var box:Box = new Box();
    levelPlane.addEventListener(MouseEvent.MOUSE_DOWN, onOver);
    box.x = box.width /2* (x + y);
    box.y = box.height/2 * (x - y);

    function onOver(e:MouseEvent):void{
    var tree1:Tree1 = new Tree1();
    tree.x =;

How Do i target the movieclips(BOX) inside of the main MovieClip(levelPlane)? imagine i have nested 10 boxes inside a MovieClip Called "levelPlane" i want to click on any of the boxes to add another Mc on the box i clicked x,y location.

2012-04-04 05:01
by joshua


If I understand correctly, you are trying to place the newly created movie clip on top of the other, but they are not within the same coordinate space. The target's coordinates must be translated to tree1's coordinate space, for both of them to have the same position:

var tree1:Tree1 = new Tree1();

var global:Point = Point (,;
var local:Point = globalToLocal(global);
tree1.x = local.x;
tree1.y = local.y;
2012-04-04 07:25
by weltraumpirat
champion, so close i will have to rework it as these new mc tree are effecting the globals cause there in the way .. thank yo - joshua 2012-04-04 07:35


The Event.currentTarget property refers to the current object processing the event, i.e., the listener object. If you want reference to the object which dispatched the event, use

2012-04-04 05:04
by constantine1
i know. used both still have same resul - joshua 2012-04-04 05:08
Let me try to understand your question a little bit more: You want to create a new movie clip and add it to existing movieclip at the location of mouseclick - constantine1 2012-04-04 05:25
Not the mouse as i could just use tree1.x = mouseX ; I want to be able to add the mc to the position of the mc that i just clicke - joshua 2012-04-04 05:30
clickedmc = childmc.x = clickedmc.x // location of parent in its parent's coordinate system childmc.y = clickedmc.y [clickedmc.parent.addChild(childmc) This would add childmc as a sibling to clickedmc, at same location (just on top of clickedmc - constantine1 2012-04-04 05:44
i understand what your saying but this wont work, thanks for input though.. I also have all my Mc into an array so im thinking of finding the name to get its locations to place down the newly added cli - joshua 2012-04-04 06:10