Reputation: 3
I'm trying to make an object, a red circle move bounce to a random location within my stage onCLick, and display the message you touched my circle
. I don't quite know what i'm doing wrong.
Here is what i came up with
import flash.events.MouseEvent;
myCircle.addEventListener(MouseEvent.MOUSE_DOWN, onClick);
function onClick(e:MouseEvent):void
{
trace("you touched myCircle");
Math.floor(Math.random()*(1+High-Low))+Low;
}
var High = stage.stageWidth == 550, stage.stageHeight == 400;
var Low = stage.stageWidth == 0, stage.stageHeight == 0;
Upvotes: 0
Views: 4399
Reputation: 18747
var HighH:int=stage.stageHeight;
var HighW:int=stage.stageWidth;
var LowH:int=0; var LowW:int=0;
....
function onClick(e:MouseEvent):void
{
trace("you touched myCircle");
myCircle.x=Math.floor(Math.random()*(1+HighW-LowW))+LowW;
myCircle.y=Math.floor(Math.random()*(1+HighH-LowH))+LowH;
}
You need to set your circle's new coordinates, use x
and y
properties for that.
Upvotes: 2