2
如何将当前目标放入影片剪辑?ActionScript 3.0 - 如何将当前目标放入影片剪辑?
如果我们可以将当前目标设置为“selectMovieClip”变量,那么我相信我们应该能够旋转或操纵它作为MovieClip。
请复制下面的脚本,你会明白我的意思。目前我无法旋转它。
请告诉我我的脚本有什么问题。谢谢。
import flash.display.MovieClip;
/*create multiple MovieClip*/
for(var i:int = 0; i < 10; i++){
var widthSquare:int = 100;
var heightSquare:int = 100;
var square:MovieClip = new MovieClip();
square.graphics.lineStyle(1,0x0000CC);
square.graphics.beginFill(0xCCCCCC);
square.graphics.drawRect(0,0,widthSquare,heightSquare);
square.graphics.endFill();
square.name = "RotableClip_"+i;
square.x = 100 + (widthSquare*i);
square.y = 400;
addChild(square);
}
//SET MOVIECLIP
var selectMovieClip;//declare veriable
function onMousePress(evt:MouseEvent):void{
if(evt.target.name.indexOf("RotableClip_")==0){//only allow RotableClip_ to rotate
selectMovieClip=evt;
trace("Selected movie clip" + evt.target.name);
}
}
stage.addEventListener(MouseEvent.MOUSE_DOWN, onMousePress);
//Rotate MovieClip
function MouseMove(evt:Event):void{
rotateTarget();//recreate the menu
}
stage.addEventListener(MouseEvent.MOUSE_MOVE, MouseMove);
function onMouseRelease(evt:MouseEvent):void {
rotateTarget()
}
//rotateTarget OR at onMousePress
//How do we bring the movie clip into the below and rotate it.
function rotateTarget(){
selectMovieClip.rotation += 90;
trace("Rotate the movie clip");
}
那么我没有执行你的代码,但我认为PatrickS正在指导你的错误..尝试并检查。 – 2010-10-16 16:12:23
那么,我们如何将movieClip分配给“selectMovieClip”,这是实例名称。 – dngo 2010-10-18 14:08:45
我认为它得到了它。 evt.target – dngo 2010-10-18 14:14:02