簡體   English   中英

如何使用as3同時訪問所有動畫片段(以及動畫片段中的動畫片段,......)?

[英]How to access all movieclips (and movieclips inside a movieclips,…) at a sametime with as3?

我正在使用Adobe Animate(或Adobe Flash Professional),我經常使用as3導航時間軸。 我想在舞台到達精確幀時重置所有動畫片段(以及moviclip中的動畫片段)。 喜歡:

 if (this.currentFrame == 120) 
    { 
        allMovieClips.gotoAndPlay(1);
    } 

我正在考慮訪問庫中的所有動畫片段,但我不知道如何。 有沒有辦法做到這一點?

您無法訪問庫中的內容,因為庫是設計時的概念。 如果要重置當前附加到舞台的所有MovieClip實例,請執行以下操作:

import flash.display.Sprite;
import flash.display.MovieClip;

// Start resetting them from the topmost timeline.
reset(root as Sprite);

function reset(target:Sprite):void
{
    // First, browse all the children of the target.
    for (var i:int = 0; i < target.numChildren; i++)
    {
        var aChild:Sprite = target.getChildAt(i) as Sprite;

        // If a child is a container then go recursive on it.
        if (aChild) reset(aChild);
    }

    // Second, if the target is not only the container
    // of other things but a MovieClip itself then rewind it.
    if  (target is MovieClip)
        (target as MovieClip).gotoAndPlay(1);
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM