Actionscript Code:
var myTimer = new Timer(1000); // Creates a timer that goes in cycles of 1000 milliseconds until you tell it to stop.
myTimer.start(); // Starts the timer.
myTimer.addEventListener(TimerEvent.TIMER, tickTock);
myObject.addEventListener(MouseEvent.CLICK, myClick);
function tickTock(e:TimerEvent):void {
myObject.x = Math.random() * (550 - myObject.width) + 1 / 2 * myObject.width; //This is just getting creative with the code so that the whole button will always be on the screen, instead of parts of it getting cut off sometimes. You can change "myObject.width" to "(myObject.width + 10)" if you want some space between the object and the edge of the screen, changing "10" to whatever number gives it the distance from the edge that you want.
myObject.y = Math.random() * (400 - myObject.height) + 1 / 2 * myObject.height;
}
function myClick(e:MouseEvent):void {
myTimer.stop(); // It can't put the button in a random location if the timer doesn't tick!
}