package {
import enemies.Enemy;
import flash.display.Sprite;
import flash.events.*;
public class Main extends Sprite {
// a place to store the enemy
public var enemy:Enemy;
private function handleEnterFrame(e:Event):void {
tweenIt(enemy.x, mouseX, 2);
}
private function tweenIt(variable:Number, target:Number, speed:Number):void{
if (variable < target) {
variable += speed;
}
if (variable > target) {
variable -= speed;
}
}
// this is the first code that is run in our application
public function Main():void {
addEventListener(Event.ENTER_FRAME, handleEnterFrame);
// we create the enemy and store him in our variable
enemy = new Enemy();
// we add the enemy to the stage
addChild(enemy)
enemy.x = Math.random() * stage.stageWidth;
enemy.y = Math.random() * stage.stageHeight;
}
}
}
The enemy class has a bitmapped embeded into it. I am using FlashDevelop to program. When I do something like enemy.x+=1 it works, but when I try using my tween it script the enemy stands still no matter what the position of the mouse. Thank you, Blobstah