我是Flash的新手。我創建了一個包含8個不同圖層的基本屏幕保護程序。 7個是隱藏的,1個是現在玩的。我想知道在完成時間線上是否有任何方法,它會再次啓動時間線,然後顯示第二層並掩蓋第一層。然後它會做同樣的事情,掩蓋第二層並顯示第三層等等。Flash - 每次隱藏不同圖層的時間線循環
我可能已經完全錯誤的方式去了,但任何指導將不勝感激。
謝謝!
我是Flash的新手。我創建了一個包含8個不同圖層的基本屏幕保護程序。 7個是隱藏的,1個是現在玩的。我想知道在完成時間線上是否有任何方法,它會再次啓動時間線,然後顯示第二層並掩蓋第一層。然後它會做同樣的事情,掩蓋第二層並顯示第三層等等。Flash - 每次隱藏不同圖層的時間線循環
我可能已經完全錯誤的方式去了,但任何指導將不勝感激。
謝謝!
您無法使用actionscript隱藏/顯示圖層,但可以打開和關閉可見性。
您的每個圖層都可能是它自己的MovieClip(如果它們不是,則嘗試使每個圖層都有自己的MovieClip)。給每個這些實例名稱(screen1,screen2等)。然後,您需要創建一個捕獲時間線的事件處理程序,並在發生這種情況時讓您執行一些代碼。可能有必要使自己的幀計數器變量。這段代碼將會在時間軸的第一幀(通常在它自己的層)。類似這樣的:
var frameCounter:int = -1; //start at -1 so the first screen gets shown first
var currentScreen:MovieClip = screen1; //or whatever the name of the first screen is
var screens:Array = [screen1, screen2, screen3, screen4, screen5]; //load your screens into an array so it's easier to cycle through them
//make sure all of the screens are hidden to begin with
for each(var screen:MovieClip in screens) {
screen.visible = false;
}
this.stage.addEventListener(Event.ENTER_FRAME, handleEnterFrame);
function handleEnterFrame(evt:Event):void {
frameCounter++;
if(frameCounter == this.totalFrames) {
frameCounter = 0; //just to be sure this value resets properly
}
if(frameCounter == 0) {
var indexOfCurrentScreen = screens.indexOf(currentScreen);
var indexOfNextScreen = indexOfCurrentScreen + 1;
if(indexOfNextScreen >= screens.length) {
indexOfNextScreen = 0; //to make sure we're not out of the array bounds
}
//hide the last screen, show the next one
currentScreen.visible = false;
currentScreen = screens[indexOfNextScreen] as MovieClip;
currentScreen.visible = true;
}
}
希望這足以讓你起步良好。請記住,此代碼應位於主時間軸第一幀的其自己的關鍵幀中。通常最好在其自己的層中創建該關鍵幀,並將其稱爲「操作」。
事實上,最好的做法是不要在時間軸上有任何代碼,而是使用.as(actionscript)文件來組織代碼。但這是另一天的話題,目前,這個解決方案可能會做得很好。
祝你好運!
這真的很有用!謝謝! –
不,你不能用actionscript隱藏/顯示圖層。 – Cyclonecode