我必須將對象列表添加到數組中,以便可以訪問它們稍後,但由於某種原因,我添加的對象之前播放過,我將它們添加到顯示列表中。這裏是代碼:影片剪輯在它被添加到DisplayList之前工作嗎?
框架凡列表添加:
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中的動畫片段開始播放之前它甚至被添加到顯示列表中,我不確定是什麼導致它...我不能在這個框架中單獨添加變量,因爲框架1中還有其他選項會導致我創建一個數組。