Hello everyone, I'm sort of a beginner at ActionScript 3.0 (and at Flash in general, for that matter), and am currently having trouble with one of my first scripts. I am currently trying to get a MovieClip to randomly bounce around the page and resize. The script I have so far works, but a strange error shows up when you leave the flash file open for a while. After a couple minutes, the MovieClip becomes stretched out, with the width of the MovieClip becoming longer than the height, proportionally. Considering the fact that I am using multiplication to scale the image, this is very confusing to me. Can someone please take a look at my code and tell me my mistake? Thank you for your time.
Also, here is a link to the .swf in action: http://www.thebiasphere.org/
var thebiasphere:MovieClip = new Globe();
addChild(thebiasphere);
thebiasphere.x = stage.stageWidth/2;
thebiasphere.y = stage.stageHeight/2;
var sizedown:Boolean = true;
var sizeup:Boolean = false;
var action:String = "down";
var xvel:Number = 0;
var yvel:Number = 0;
var destinationx:Number = Math.random()*stage.stageWidth;
var destinationy:Number = Math.random()*stage.stageHeight;
addEventListener(Event.ENTER_FRAME, movearound);
function movearound(evt:Event):void {
if (thebiasphere.width<200) {
action="up";
}
if (thebiasphere.width>800) {
action="down";
}
if (thebiasphere.x>destinationx-5 && thebiasphere.x<destinationx+5) {
destinationx = Math.random()*stage.stageWidth;
}
if (thebiasphere.y>destinationy-5 && thebiasphere.y<destinationy+5) {
destinationy = Math.random()*stage.stageHeight;
}
switch (action) {
case "up" :
thebiasphere.width*=1.001;
thebiasphere.height*=1.001;
break;
case "down" :
thebiasphere.width*=.999;
thebiasphere.height*=.999;
break;
}
xvel = newvel(thebiasphere.x, destinationx, 75);
yvel = newvel(thebiasphere.y, destinationy, 75);
thebiasphere.x += xvel;
thebiasphere.y += yvel;
}
function newvel(orig:Number, dest:Number, cnst:Number):Number {
return (dest - orig) / cnst;
}