1119: 访问可能未定义的属性 MOUSE_DOWN (通过 static 类型 Class) 求解答 5
package{importflash.display.Sprite;importflash.events.Event;importflash.events.MouseE...
package {
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
public class Easint2 extends Sprite{
private var targetX:Number=stage.stageWidth/2;
private var targetY:Number=stage.stageHeight/2;
private var easing:Number=.2;
private var ball:Ball;
public function Easint2() {
// constructor code
init();
}
private function init():void{
ball=new Ball();
addChild(ball);
ball.x=0;
ball.y=0;
addEventListener(Event.ENTER_FRAME,move)
ball.addEventListener(MouseEvent.MOUSE_DOWN,down);//出错
}
private function down(event:MouseEvent):void{
ball.startDrag();
removeEventListener(Event.ENTER_FRAME,move);
stage.addEventListener(MouseEvent.MOUSE_UP,up);//出错
}
private function up(event:MouseEvent):void{
ball.stopDrag();
addEventListener(Event.ENTER_FRAME,move);
stage.removeEventListener(MouseEvent.MOUSE_UP,up);//出错
}
private function move(event:Event):void{
var dx:Number=targetX-ball.x;
var dy:Number=targetY-ball.y;
ball.vx=dx*easing;
ball.vy=dy*easing;
ball.x+=ball.vx;
ball.y+=ball.vy;
}
}
} 展开
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
public class Easint2 extends Sprite{
private var targetX:Number=stage.stageWidth/2;
private var targetY:Number=stage.stageHeight/2;
private var easing:Number=.2;
private var ball:Ball;
public function Easint2() {
// constructor code
init();
}
private function init():void{
ball=new Ball();
addChild(ball);
ball.x=0;
ball.y=0;
addEventListener(Event.ENTER_FRAME,move)
ball.addEventListener(MouseEvent.MOUSE_DOWN,down);//出错
}
private function down(event:MouseEvent):void{
ball.startDrag();
removeEventListener(Event.ENTER_FRAME,move);
stage.addEventListener(MouseEvent.MOUSE_UP,up);//出错
}
private function up(event:MouseEvent):void{
ball.stopDrag();
addEventListener(Event.ENTER_FRAME,move);
stage.removeEventListener(MouseEvent.MOUSE_UP,up);//出错
}
private function move(event:Event):void{
var dx:Number=targetX-ball.x;
var dy:Number=targetY-ball.y;
ball.vx=dx*easing;
ball.vy=dy*easing;
ball.x+=ball.vx;
ball.y+=ball.vy;
}
}
} 展开
Storm代理
2023-08-29 广告
2023-08-29 广告
"StormProxies是全球大数据IP资源服务商,其住宅代理网络由真实的家庭住宅IP组成,可为企业或个人提供满足各种场景的代理产品。点击免费测试(注册即送1G流量)StormProxies有哪些优势?1、IP+端口提取形式,不限带宽,I...
点击进入详情页
本回答由Storm代理提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询