0
package { import flash.display。 ; 導入flash.events。; import flash.net。*;當我使用e.currentTarget在一個函數中移動一個對象時,什麼也沒有發生
public class exp1 extends Sprite
{
var directionX:Number = 5;
var directionY:Number = Math.random()*5;
public function exp1()
{
var loader:Loader = new Loader();
var request = new URLRequest("monkeyproj-1.jpg");
loader.load(request);
addChild(loader);
loader.x = 100;
loader.scaleY = 0.5;
var recA:Sprite = new Sprite;
recA.graphics.beginFill(0xFFF010);
recA.graphics.lineStyle(1);
recA.graphics.drawRect(40, 280, 50, 20);
addChild(recA);
recA.x = 300;
recA.y = 300;
recA.scaleX = 2;
recA.scaleY = 2;
recA.addEventListener(Event.ENTER_FRAME, moveRecA);
}
function moveRecA(e:Event){
e.currentTarget.y +=directionY;
e.currentTarget.x +=directionX;
}
}
}