flash as3.0影片剪辑随鼠标点击移动代码
1个回答
展开全部
就是点击时更新影片剪辑的坐标位置,代码如:
import flash .events.MouseEvent
stage.addEventListener (MouseEvent.MOUSE_DOWN ,moveing)
function moveing(e:MouseEvent ):void {
mc.x+=5
}
移动到鼠标点击时的位置:
import flash.events.MouseEvent;
stage.addEventListener(MouseEvent.MOUSE_DOWN ,moveing);
function moveing(e:MouseEvent ):void
{
mc.x = mouseX;
mc.y = mouseY;
}
移动到鼠标点击时的位置,有移动动画:
import flash.events.Event;
import flash.events.MouseEvent;
var clickX:Number = 0;
var clickY:Number = 0;
stage.addEventListener(MouseEvent.CLICK ,moveing);
function moveing(e:MouseEvent ):void
{
clickX = mouseX;
clickY = mouseY;
mc.addEventListener(Event.ENTER_FRAME ,loop);
}
function loop(e:Event ):void
{
e.target.x += (clickX - e.target.x) * .2;
e.target.y += (clickY - e.target.y) * .2;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询