感谢您花时间回答我的问题。所以问题是制作一个简单的矩形跟随我的鼠标。我真的不明白为什么这段代码不起作用。包类
{
import flash.display.MovieClip;
import flash.display.Stage;
import flash.events.Event;
public class watever extends MovieClip
{
var stageRef:Stage;
public function watever(x:Number, y:Number, stageRef:Stage)
{
this.x = x;
this.y = y;
this.stageRef = stageRef;
addEventListener(Event.ENTER_FRAME, moveMe, false, 0, true);
}
public function moveMe(e:Event):void
{
this.x = mouseX;
this.y = mouseY;
trace(mouseX);
}
}
}
该对象只是在“奇怪”的地方,所以我试图追踪 mouseX,我在输出中得到了愚蠢的数字
-1373
1790
-1373
1790
-1373
1790
-1373
1790
-1373
1790
-1373
1790
-1373
但是,如果我从父类声明它,它工作正常。请问代码有什么问题吗?(以下是它在父类中的工作方式)
public function DocumentClass()
{
c = new watever(200, 200, stage)
stage.addChild(c);
addEventListener(Event.ENTER_FRAME, loop, false, 0, true);
}
private function loop(e:Event):void
{
c.x = mouseX;
c.y = mouseY;
}