flash2.0把一个元件拖动到某一位置,跳转至第5帧一帧
发布网友
发布时间:2024-01-03 08:30
我来回答
共1个回答
热心网友
时间:2024-01-31 05:28
可拖动的元件实例名为drag_mc,表示区域的元件实例名为area_mc,代码如下:
var tempX:Number=0;
var tempY:Number=0;
drag_mc.onPress=function()
{
tempX=this._parent._xmouse-this._x;
tempY=this._parent._ymouse-this._y;
this.onEnterFrame=function()
{
this._x=this._parent._xmouse-tempX;
this._y=this._parent._ymouse-tempY;
}
}
drag_mc.onRelease=function()
{
this.onEnterFrame=null;
if(Math.abs(area_mc._x-drag_mc._x)<area_mc._width/2+drag_mc._width/2&&Math.abs(area_mc._y-drag_mc._y)<area_mc._height/2+drag_mc._height/2)
{
this._parent.gotoAndStop(5);
}
}