ActionScript 3 How do I "move" coins when a player movieclip touches it

46 views Asked by At

So let's say I have a circle object that I can move around in an open field, essentially I want to know if its possible to move the coin to a random spot, giving it an illusion of collecting a coin and spawning a new one. However I can't seem to move it when my object symbol touches the coin, can I get some help?

var randomX:Number = Math.random() * stage.stageWidth
var randomY:Number = Math.random() * stage.stageHeight
var coin:item_point = new item_point;
coin.x = randomX;
coin.y = randomY;
addChild(coin);
addEventListener(Event.ENTER_FRAME, interaction);
function interaction(event:Event):void
{
    if (mc_circle.hitTestObject(coin)){
        total += 100;
        coin.x = randomX;
        coin.y = randomY;
}
0

There are 0 answers