Problem sending looped event.CurrentTarget to start position
Hi there,
I've got a problem with an if/else statement within a function which checks to see which 'drop area' one of ten items should to snap to.. the problem is I can only set the start location of each item to work on the first hitTest, otherwise after clicking another item or positioning any item in one of the drop areas, the drop area becomes it's start location due to startDrag() and stopDrag() been called again to move the object..
What I've tried to do here is to create a variable (which does trace the correct (currentTargetHome) movieclip reference, but as a string) but it doesn't work when I try to access it's attributes using [currentTargetHome].
The item exists within the movieclip "gamePage" and the rest of the function works !
Any ideas would be appreciated
Thanks in advance..
function persoMouseUp(event:MouseEvent):void {
var homeHitArray:Array = [gamePage.a1b, gamePage.a2b, gamePage.a3b, gamePage.a4b, gamePage.a5b];
event.currentTarget.stopDrag();
var currentTargetHome:String = "gamePage." + event.currentTarget.name + "b";
//var currentHome:DisplayObject = getChildByName(currentTargetHome);
gamePage.h2.visible = false;
gamePage.h3.visible = false;
gamePage.h4.visible = false;
for(var i:Number = 0; i < homeHitArray.length; i++){
if(event.currentTarget.hitTestObject(homeHitArray)) {
event.currentTarget.x = (homeHitArray).x;
event.currentTarget.y = (homeHitArray).y;
} else if(event.currentTarget.hitTestObject(gamePage.h2)) {
event.currentTarget.x = gamePage.h2.x;
event.currentTarget.y = gamePage.h2.y;
} else if(event.currentTarget.hitTestObject(gamePage.h3)) {
event.currentTarget.x = gamePage.h3.x;
event.currentTarget.y = gamePage.h3.y;
} else if(event.currentTarget.hitTestObject(gamePage.h4)) {
event.currentTarget.x = gamePage.h4.x;
event.currentTarget.y = gamePage.h4.y;
} else {
event.currentTarget.x = [currentTargetHome].x;
event.currentTarget.y = [currentTargetHome].y;
//trace(currentTargetHome);
}
}
}