1个回答
展开全部
复制如下代码即可:
var speed:Number = 5; //设置mc的移动速度
var mc:MovieClip;
var p:Point = new Point(0,0);
var timer:Timer = new Timer( 40 );
stage.addEventListener(MouseEvent.CLICK , clickHandler );
function clickHandler( e ){
p.x = mouseX;
p.y = mouseY;
timer.addEventListener("timer" , timerHandler );
timer.start();
}
function timerHandler( e ){
var xl:Number = p.x - mc.x;
var yl:Number = p.y - mc.y;
var zl:Number = Math.sqrt( xl * xl + yl * yl );
if( zl >= speed ){
mc.x += xl / zl * speed;
mc.y += yl / zl * speed;
}else{
mc.x = p.x;
mc.y = p.y;
timer.stop();
timer.removeEventListener("timer" , timerHandler );
}
}
stop();
绝对负责任的回答,我都是开着flash回答问题的,先试验,再回答!!
var speed:Number = 5; //设置mc的移动速度
var mc:MovieClip;
var p:Point = new Point(0,0);
var timer:Timer = new Timer( 40 );
stage.addEventListener(MouseEvent.CLICK , clickHandler );
function clickHandler( e ){
p.x = mouseX;
p.y = mouseY;
timer.addEventListener("timer" , timerHandler );
timer.start();
}
function timerHandler( e ){
var xl:Number = p.x - mc.x;
var yl:Number = p.y - mc.y;
var zl:Number = Math.sqrt( xl * xl + yl * yl );
if( zl >= speed ){
mc.x += xl / zl * speed;
mc.y += yl / zl * speed;
}else{
mc.x = p.x;
mc.y = p.y;
timer.stop();
timer.removeEventListener("timer" , timerHandler );
}
}
stop();
绝对负责任的回答,我都是开着flash回答问题的,先试验,再回答!!
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询