# I'm gonna break something...!

**URL:** <https://forum.kirupa.com/t/im-gonna-break-something/295121>\
**Category:** flash\
**Created:** [August 25, 2009, 5:04pm UTC](https://forum.kirupa.com/t/im-gonna-break-something/295121 "2009-08-25T17:04:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![KEtCHUP](https://avatars.discourse-cdn.com/v4/letter/k/b9e5f3/32.png) [@KEtCHUP](https://forum.kirupa.com/u/KEtCHUP)\
**Post date:** [August 25, 2009, 5:04pm UTC](https://forum.kirupa.com/t/im-gonna-break-something/295121/1 "2009-08-25T17:04:56Z")

</div>

```auto

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!?!?!?
