//AS2.0所用代码
MC为影片剪辑MovieCilp
mc1.onRelease=function()
{
mc1.stopDrag();
mc1._x=Math.random()*500+10;
mc1._y=Math.random()*350+10;
}
场景宽度500*350
注意:影片剪辑名称要和代码一致。
//AS3.0所用代码
var myMC:MovieClip;
var mySprite:Sprite;
initMyMC(initMySprite());
myMC.addEventListener(MouseEvent.MOUSE_DOWN,onDown);
myMC.addEventListener(MouseEvent.MOUSE_UP,onUp);
function initMySprite():Sprite
{
mySprite=new Sprite();
mySprite.graphics.beginFill(0x00ff66,.8);
mySprite.graphics.drawCircle(0,0,30);
mySprite.graphics.endFill();
return mySprite;
}
function initMyMC(sprite:*)
{
myMC=new MovieClip();
myMC.addChild(sprite);
addChild(myMC);
myMC.x=myMC.y=10;
}
function onDown(evt:MouseEvent)
{
evt.target.startDrag();
}
function onUp(evt:MouseEvent)
{
with(evt.target)
{
stopDrag();
x=Math.random()*250;
y=Math.random()*250;
}
}
//代码面向对应的影片剪辑动作
转载请注明:http://www.drmscn.com/
0 Response to “flash点击触发MovieCilp影片剪辑随机运动方法”