Animate CC workframe如何阻止此程序循环?停止();功能不起作用。它不是动画片段而是拖放游戏。因为我还是AS3的新手,如果有人用解释回答我的问题,我将不胜感激。谢谢!
item1.objName = "circle";
item1.initX = item1.x;
item1.initY = item1.y;
item1.val = 0;
item2.objName = "rectangle";
item2.initX = item2.x;
item2.initY = item2.y;
item2.val = 0;
item3.objName = "triangle";
item3.initX = item3.x;
item3.initY = item3.y;
item3.val = 0;
bin1.shape.alpha = 0;
bin2.shape.alpha = 0;
bin3.shape.alpha = 0;
item1.buttonMode = true;
item2.buttonMode = true;
item3.buttonMode = true;
item1.addEventListener(MouseEvent.MOUSE_DOWN, mousePress);
item1.addEventListener(MouseEvent.MOUSE_UP, mouseRelease);
item2.addEventListener(MouseEvent.MOUSE_DOWN, mousePress);
item2.addEventListener(MouseEvent.MOUSE_UP, mouseRelease);
item3.addEventListener(MouseEvent.MOUSE_DOWN, mousePress);
item3.addEventListener(MouseEvent.MOUSE_UP, mouseRelease);
//Mouse Events
function mousePress(event:MouseEvent):void {
var item:MovieClip = MovieClip(event.target);
item.startDrag();
item.scaleX = item.scaleY = .95;
var topPos:uint = this.numChildren - 1;
this.setChildIndex(item, topPos);
ilabel.itemName_txt.text = item.objName;
}
function mouseRelease(event:MouseEvent):void {
var item:MovieClip = MovieClip(event.target);
item.stopDrag();
switch (item.objName) {
case "circle" :
if (bin1.hitTestObject(item)){
updateShape(item, bin1);
}
else{
ilabel.info_txt.text ="WRONG! Hint: circle";
item.scaleX = item.scaleY = 1
}
break;
case "rectangle" :
if (bin2.hitTestObject(item)) {
updateShape(item, bin2);
}
else{
ilabel.info_txt.text ="WRONG! Hint: rectangle";
item.scaleX = item.scaleY = 1
}
break;
case "triangle" :
if (bin3.hitTestObject(item)){
updateShape(item, bin3);
}
else{
ilabel.info_txt.text ="WRONG! Hint: Triangle";
item.scaleX = item.scaleY = 1
}
break;
default :;
}
}
function updateShape(item:MovieClip, bin:MovieClip):void {
ilabel.itemName_txt.text = "";
item.scaleX = item.scaleY = 1;
item.visible = false;
ilabel.info_txt.text ="CORRECT! ";
bin.shape.alpha = 1;
item.val = 1;
resetShapes();
}
function resetShapes(){
if((item1.val == 1)&& (item2.val == 1) && (item3.val == 1)){
item1.x = item1.initX;
item1.y = item1.initY;
item2.x = item2.initX;
item2.y = item2.initY;
item3.x = item3.initX;
item3.y = item3.initY;
bin1.shape.alpha = 0;
bin2.shape.alpha = 0;
bin3.shape.alpha = 0;
item1.visible = true;
item2.visible = true;
item3.visible = true;
item1.val = 0;
item2.val = 0;
item3.val = 0;
}
}
function checkGame():void {
if ((item1.scaleX = item1.scaleY = 1)&& (item2.scaleX = item2.scaleY = 1)&&(item3.scaleX = item3.scaleY = 1))
{
ilabel.info_txt.text=" Well done!";
}
}
答案 0 :(得分:0)
function checkGame():void {
if ((item1.scaleX = item1.scaleY = 1)&& (item2.scaleX = item2.scaleY = 1)&&(item3.scaleX = item3.scaleY = 1))
{
ilabel.info_txt.text=" Well done!";
item1.removeEventListener(MouseEvent.MOUSE_DOWN, mousePress);
item1.removeEventListener(MouseEvent.MOUSE_UP, mouseRelease);
item2.removeEventListener(MouseEvent.MOUSE_DOWN, mousePress);
item2.removeEventListener(MouseEvent.MOUSE_UP, mouseRelease);
item3.removeEventListener(MouseEvent.MOUSE_DOWN, mousePress);
item3.removeEventListener(MouseEvent.MOUSE_UP, mouseRelease);
}
这将阻止用户选择任何内容。 如果你有一个电影剪辑循环' item1'例如。 你需要添加item1.stop();还有checkGame功能...
祝你好运!