我目前正在兼职MA,必须在Flash中创建一个项目。我有一个拖放的场景,但是'掉线'元素延续到下一个场景之上。我试图使用AS3将它们设置为在下一个场景后删除。单击按钮但没有快乐。我非常感谢你的帮助!
我看到有人在网上说我根本不应该使用场景,任何物品都应该在AS3中添加,而不是在时间线上掉到舞台上但不幸的是这样做了。我如何被展示,重建可能为时已晚。我应该在我的AS中添加什么才能使其清除'在进入下一个或上一个场景之前的阶段?
var orig1X:Number=Object1_mc.x;
var orig1Y:Number=Object1_mc.y;
var orig2X:Number=Object2_mc.x;
var orig2Y:Number=Object2_mc.y;
var orig3X:Number=Object3_mc.x;
var orig3Y:Number=Object3_mc.y;
var orig4X:Number=Object4_mc.x;
var orig4Y:Number=Object4_mc.y;
var orig5X:Number=Object5_mc.x;
var orig5Y:Number=Object5_mc.y;
Object1_mc.addEventListener(MouseEvent.MOUSE_DOWN, dragTheObject);
Object1_mc.addEventListener (MouseEvent.MOUSE_UP, item1Release);
Object2_mc.addEventListener(MouseEvent.MOUSE_DOWN, dragTheObject);
Object2_mc.addEventListener (MouseEvent.MOUSE_UP, item2Release);
Object3_mc.addEventListener(MouseEvent.MOUSE_DOWN, dragTheObject);
Object3_mc.addEventListener (MouseEvent.MOUSE_UP, item3Release);
Object4_mc.addEventListener(MouseEvent.MOUSE_DOWN, dragTheObject);
Object4_mc.addEventListener (MouseEvent.MOUSE_UP, item4Release);
Object5_mc.addEventListener(MouseEvent.MOUSE_DOWN, dragTheObject);
Object5_mc.addEventListener (MouseEvent.MOUSE_UP, item5Release);
function dragTheObject(event:MouseEvent):void {
var item:MovieClip=MovieClip(event.target);
item.startDrag();
var topPos:uint=this.numChildren-1;
this.setChildIndex(item, topPos);
}
function item1Release(event:MouseEvent):void {
var item:MovieClip=MovieClip(event.target);
item.stopDrag();
if (TargetObject1_mc.hitTestPoint(item.x,item.y)) {
item.x=TargetObject1_mc.x;
item.y=TargetObject1_mc.y;
} else {
item.x=orig1X;
item.y=orig1Y;
}
};
function item2Release(event:MouseEvent):void {
var item:MovieClip=MovieClip(event.target);
item.stopDrag();
if (TargetObject2_mc.hitTestPoint(item.x,item.y)) {
item.x=TargetObject2_mc.x;
item.y=TargetObject2_mc.y;
} else {
item.x=orig2X;
item.y=orig2Y;
}
};
function item3Release(event:MouseEvent):void {
var item:MovieClip=MovieClip(event.target);
item.stopDrag();
if (TargetObject3_mc.hitTestPoint(item.x,item.y)) {
item.x=TargetObject3_mc.x;
item.y=TargetObject3_mc.y;
} else {
item.x=orig3X;
item.y=orig3Y;
}
};
function item4Release(event:MouseEvent):void {
var item:MovieClip=MovieClip(event.target);
item.stopDrag();
if (TargetObject4_mc.hitTestPoint(item.x,item.y)) {
item.x=TargetObject4_mc.x;
item.y=TargetObject4_mc.y;
} else {
item.x=orig4X;
item.y=orig4Y;
}
};
function item5Release(event:MouseEvent):void {
var item:MovieClip=MovieClip(event.target);
item.stopDrag();
if (TargetObject5_mc.hitTestPoint(item.x,item.y)) {
item.x=TargetObject5_mc.x;
item.y=TargetObject5_mc.y;
} else {
item.x=orig5X;
item.y=orig5Y;
}
};
function reset(event:MouseEvent):void {
Object1_mc.x=orig1X;
Object1_mc.y=orig1Y;
Object2_mc.x=orig2X;
Object2_mc.y=orig2Y;
Object3_mc.x=orig3X;
Object3_mc.y=orig3Y;
Object4_mc.x=orig4X;
Object4_mc.y=orig4Y;
Object5_mc.x=orig5X;
Object5_mc.y=orig5Y;
}
Reset_btn1.addEventListener(MouseEvent.CLICK, reset);
Object1_mc.buttonMode = true;
Object2_mc.buttonMode = true;
Object3_mc.buttonMode = true;
Object4_mc.buttonMode = true;
Object5_mc.buttonMode = true;
button_12.addEventListener(MouseEvent.CLICK, fl_ClickToGoToPreviousScene_7);
function fl_ClickToGoToPreviousScene_7(event:MouseEvent):vo id
{
MovieClip(this.root).prevScene();
}
movieClip_13.addEventListener(MouseEvent.CLICK, fl_ClickToGoToNextScene_15);
function fl_ClickToGoToNextScene_15(event:MouseEvent):void
{
MovieClip(this.root).nextScene();
}