由于库是设计时概念,因此无法访问库中的内容。如果你想重置所有目前连接到舞台的影片剪辑实例,请执行以下操作:
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);
}
ummmm - 你可以在运行时,只要该项目被赋予了联动访问库。 http://stackoverflow.com/questions/22940461/loading-and-unloading-content-from-library-in-as3但我仍然要+1,因为这种递归算法将确实解决问题。 – Zze
@Zze,所有应有的尊重,库是一个原型的调色板,你不能访问它的内容运行时。只要它们与AS3类相关联,你就可以用“新”运算符来实例化事物,但这就是它的范围。您不能从库中删除项目,您无法修改它们。更糟的是,除非你知道各自的AS3类,否则你甚至不能列出链接的链接。 – Organis
这是正确的,但我所说的是,你可以**访问**图书馆。你可以从中实例化。我没有列出任何其他功能列出。我只是认为“你不能访问图书馆里的东西”是不正确的 - 就像你刚才所说的那样。也许应该是“你不能操纵图书馆里的东西”。不争论图书馆是低于平均水平 - 哈哈 – Zze