Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Arrays 电影剪辑在添加到显示列表之前是否正常工作?_Arrays_Actionscript 3 - Fatal编程技术网

Arrays 电影剪辑在添加到显示列表之前是否正常工作?

Arrays 电影剪辑在添加到显示列表之前是否正常工作?,arrays,actionscript-3,Arrays,Actionscript 3,我必须将对象列表添加到数组中,以便以后可以访问它们,但由于某些原因,我添加的对象以前播放过,我将它们添加到显示列表中。代码如下: 添加列表的框架: sunny.addEventListener(MouseEvent.CLICK, sunny_choice); function sunny_choice(E:MouseEvent) { var sunny_walkcycle: Sunny_Walkcycle = new Sunny_Walkcycle (); var sunny_

我必须将对象列表添加到数组中,以便以后可以访问它们,但由于某些原因,我添加的对象以前播放过,我将它们添加到显示列表中。代码如下:

添加列表的框架:

sunny.addEventListener(MouseEvent.CLICK, sunny_choice);

function sunny_choice(E:MouseEvent)
{
    var sunny_walkcycle: Sunny_Walkcycle = new Sunny_Walkcycle ();
    var sunny_busstop : Sunny_BusStop = new Sunny_BusStop ();
    var sunny_opening: Teacher_Opening_Sunny = new Teacher_Opening_Sunny ();


    clothingArray.push( sunny_walkcycle);
    clothingArray.push( sunny_busstop);
    clothingArray.push( sunny_opening);

    trace("Sunny");
    cleaner();
//cleaner just removes the event listener and asks it to go to the next frame
}
下一帧:

clothingArray [0].scaleX = -1;

addChild (clothingArray [0]);
clothingArray[0].x = 633;
clothingArray[0].y = 174;
clothingArray [0].stop ();
clothingArray [0].addEventListener (MouseEvent.CLICK, transforming);


function transforming (e:MouseEvent) {
    if (clothingArray [0].currentFrame == clothingArray [0].totalFrames) {
        clearall2 ();

    }
    else{
    clothingArray  [0].nextFrame();
    moving_background.nextFrame ();
    }

}
function clearall2 () {
    clothingArray [0].removeEventListener (MouseEvent.CLICK, transforming);
    removeChild (clothingArray [0]);

    gotoAndStop (3);
}
问题是:

addChild (clothingArray [1]);
clothingArray[1].addEventListener (Event.ENTER_FRAME , busstop);
trace ("The Current Frame is " + clothingArray [1].currentFrame);
function busstop (d:Event) {
        if (clothingArray [1].currentFrame == clothingArray  [1].totalFrames) {
        clearall3 ();

    }
}

function clearall3 () {
    removeChild (clothingArray [1]);
    clothingArray[1].removeEventListener (Event.ENTER_FRAME , busstop);

    }

因此,它的确切作用是第3帧中的movieclip在被添加到显示列表之前就开始播放,我不确定是什么导致了它…我无法在此帧中单独添加变量,因为第1帧中还有其他选项导致我制作数组。

假设Sunny\u Walkcycle,Sunny\u bustop,老师\u Opening\u Sunny是MovieClip,为什么不在内存分配后直接使用stop()

  var sunny_walkcycle:Sunny_Walkcycle = new Sunny_Walkcycle ();
  var sunny_busstop:Sunny_BusStop = new Sunny_BusStop ();
  var sunny_opening:Teacher_Opening_Sunny = new Teacher_Opening_Sunny ();

  sunny_walkcycle.stop();
  sunny_busstop.stop();
  sunny_opening.stop();
确保MovieClip内部框架中没有会干扰控制代码的代码。 就像一出戏一样。。。藏在某处

您也可以尝试(对于sunny_Bustop),在插入阵列后:

clothingArray[1].stop();


是的,MovieClip创建后将开始播放。它不需要添加到要激活的显示列表中。这是需要了解的非常重要的细节

“显示”列表仅确定显示对象是否连接到后台层次

解决方案。。。创建后调用
stop()
方法,然后在将它们添加到显示列表时调用
play()
方法

如果从显示列表中删除时不调用
stop()
方法,它将继续消耗cpu周期。如果你有很多关于tweens等的电影,这可能是非常重要的

clothingArray[1].gotoAndStop(1);