var itemsArray:Array = new Array();
function dropLoot(enemy):Void{
var targetx:Number=enemy._x;
var targety:Number=enemy._y;
trace("1: "+targetx+" "+targety);
odds=Math.random(1);
if (odds<=.25){
var tempItem:MovieClip = _root.attachMovie("ammo", "ammo" + _root.getNextHighestDepth(), _root.getNextHighestDepth());
}
else{
var tempItem:MovieClip = _root.attachMovie("coin", "coin"+_root.getNextHighestDepth(),_root.getNextHighestDepth());
}
tempItem._x=targetx;
tempItem._y=targety;
trace("DROPPING ITEM at: "+tempItem._x+", "+tempItem._y);
itemsArray.push(tempItem);
}
So, my issue is this:
I pass in the enemy’s location that’s dropping the loot, which becomes targetx and targety.
I trace that out, it gives me (what I assume is) an accurate position. I then attach a movie clip (depending on Random). After it decides which clip to make (coin or ammo), it sets the _x and _y of tempItem to targetx and targety.
Because it didn’t work, I traced out tempItem._x and y, and they give me undefined, even though when I trace targetx and targety in the same spot, they are defined. WHAT AM I DOING WRONG!?!?!?