Flash Actionscript 问题,高手请进!

来源:百度知道 编辑:UC知道 时间:2024/06/02 20:15:13
如何用Actionscript做出下面的效果,在运行时用鼠标点击选中舞台上一个图案,然后移动鼠标图片会随着鼠标一起移动.然后再次点击鼠标,图片就停在目前的鼠标所在位置

首先在场景创建一个你需要的MC

我用的名字是my_mc

然后在帧上输入以下代玛:

var withMouse:Boolean=false;

my_mc.onRelease=function()
{
if(withMouse==false)
{
this.onEnterFrame=function()
{
this._x=_xmouse
this._y=_ymouse
_root.withMouse=true
}
}else
{
delete this.onEnterFrame;
_root.withMouse=false
}
}

把下面的脚本写在影片剪辑上
注意:是"动作-影片剪辑"

on(press, dragOut){
startDrag(this,false);
}
on(release, releaseOutside){
stopDrag();
}