电影剪辑仍会出现在下一个场景中我的代码有什么问题?

时间:2017-08-02 17:46:14

标签: actionscript-3 flash actionscript

每次你将一个不正确的盒子拖放到target_mc上时,该框出现在下一个场景中并且不会消失为什么会这样?非常感谢你的帮助。代码是actionscript 3,应用程序是在adobe动画中制作的。除非重新启动,否则该框在应用程序中的任何位置都不会消失。

stop();



import flash.events.TouchEvent;
import flash.ui.Multitouch;
import flash.ui.MultitouchInputMode;
import flash.display.MovieClip;

/* Touch and Drag Event
Allows the object to be moved by holding and dragging the object.
*/
var objectoriginalXX:Number;
var objectoriginalYY:Number;



var countApple:int = 0;


Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;

var apples:Array = [apple1_mc, apple2_mc, apple3_mc, apple4_mc, apple5_mc];

for each(var appleMC:MovieClip in apples)
{
appleMC.buttonMode = true;
appleMC.addEventListener(TouchEvent.TOUCH_BEGIN, pickobject1);
appleMC.addEventListener(TouchEvent.TOUCH_END, dropobject1);

appleMC.startX = appleMC.x;
appleMC.startY = appleMC.y;

}
var fl_DragBounds1:Rectangle = new Rectangle(0, 0, stage.stageWidth, stage.stageHeight);


function pickobject1(event:TouchEvent):void
{
    event.target.startTouchDrag(event.touchPointID, false, fl_DragBounds1);
    event.target.parent.addChild(event.target);
    objectoriginalXX = event.target.x; 
    objectoriginalYY = event.target.y;


}

function dropobject1(event:TouchEvent):void
{
    if(event.target.hitTestObject(target_mc)){
        event.target.buttonMode = false;
        event.target.x = target_mc.x;
        event.target.y = target_mc.y;
        event.target.visible = false;
        wellsound.play();
        countApple ++;


    }

    if(countApple == 5)
    {

    gotoAndPlay(4072);


    }


else{
    event.target.x = event.target.startX;
    event.target.y = event.target.startY;
    event.target.buttonMode = true;
}


}

nexthomeBtn12.addEventListener(TouchEvent.TOUCH_BEGIN,onTouchBeginhomescene12);


function onTouchBeginhomescene12 (e:TouchEvent):void{

gotoAndPlay(0);
SoundMixer.stopAll();


}




var peachs:Array = [peach1_mc, peach2_mc, peach3_mc, peach4_mc, peach5_mc, peach6_mc];
for each(var peachMC:MovieClip in peachs)
{
peachMC.buttonMode = true;
peachMC.addEventListener(TouchEvent.TOUCH_BEGIN, pickobject3);
peachMC.addEventListener(TouchEvent.TOUCH_END, dropobject3);

peachMC.startX = peachMC.x;
peachMC.startY = peachMC.y;

}
var fl_DragBounds3:Rectangle = new Rectangle(0, 0, stage.stageWidth, stage.stageHeight);


function pickobject3(event:TouchEvent):void
{
    event.target.startTouchDrag(event.touchPointID, false, fl_DragBounds3);
    event.target.parent.addChild(event.target);
    objectoriginalXX = event.target.x; 
    objectoriginalYY = event.target.y;


}

function dropobject3(event:TouchEvent):void
{
    if(event.target.hitTestObject(target_null)){
        event.target.buttonMode = false;
        event.target.x = target_mc.x;
        event.target.y = target_mc.y;
        event.target.visible = false;


    }



    else{
    event.target.x = event.target.startX;
    event.target.y = event.target.startY;
    event.target.buttonMode = true;
    trysound.play();

}
}

1 个答案:

答案 0 :(得分:0)

因为场景不是单独的对象(例如精灵 MovieClip )。对于Flash Player场景只是帧的逻辑部分(为了向后兼容,并且因为设计师/动画师倾向于在主时间轴上用场景1,第10帧来思考)(而整体主时间轴是一个 MovieClip ),因此您可以添加一个子项,并且它不会影响您来回 gotoAndPlay 的方式。

混合编程和长时间线通常是一个坏主意。

因此,为了在不泄漏大量血液的情况下进行修复,您需要跟踪每个添加了 addChild removeChild 的所有内容。分别

或者,或者,在某个容器中工作,而不是主时间轴。当你转到其他框架时,容器将不会持久存在,并且其所有内容也将被销毁。