2017-02-07 30 views
1

我正在使用Adobe Animate(或Adobe Flash Professional),我经常使用as3导航时间轴。 当舞台到达一个精确的框架时,我想重置所有的影片剪辑(和动画片里面的动画片段)。 喜欢:如何在与as3同时访问所有动画片段(和动画片段内的动画片段,...)?

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

我正在考虑采取在库中的所有影片剪辑的访问,但我不知道怎么办。 有没有办法做到这一点?

回答

3

由于库是设计时概念,因此无法访问库中的内容。如果你想重置所有目前连接到舞台的影片剪辑实例,请执行以下操作:

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); 
} 
+0

ummmm - 你可以在运行时,只要该项目被赋予了联动访问库。 http://stackoverflow.com/questions/22940461/loading-and-unloading-content-from-library-in-as3但我仍然要+1,因为这种递归算法将确实解决问题。 – Zze

+0

@Zze,所有应有的尊重,库是一个原型的调色板,你不能访问它的内容运行时。只要它们与AS3类相关联,你就可以用“新”运算符来实例化事物,但这就是它的范围。您不能从库中删除项目,您无法修改它们。更糟的是,除非你知道各自的AS3类,否则你甚至不能列出链接的链接。 – Organis

+0

这是正确的,但我所说的是,你可以**访问**图书馆。你可以从中实例化。我没有列出任何其他功能列出。我只是认为“你不能访问图书馆里的东西”是不正确的 - 就像你刚才所说的那样。也许应该是“你不能操纵图书馆里的东西”。不争论图书馆是低于平均水平 - 哈哈 – Zze

相关问题