私の知る限り、パスのような引数でDisplayListを調べる方法はありません。また、。もあり[]ませんgetChildByName。
ただし、同様の効果を実現するために独自の関数を作成することもできます(テスト済みで機能します)。
/**
* Demonstration
*/
public function Main() {
// returns 'movieclip2':
trace((container['movieclip']['movieclip2']).name);
// returns 'movieclip':
trace(path(container, "movieclip").name);
// returns 'movieclip2':
trace(path(container, "movieclip.movieclip2").name);
// returns 'movieclip2':
trace(path(container, "movieclip#movieclip2", "#").name);
// returns null:
trace(path(container, "movieclip.movieclipNotExisting"));
}
/**
* Returns a DisplayObject from a path, relative to a root container.
* Recursive function.
*
* @param root element, the path is relative to
* @param relativePath path, relative to the root element
* @param separator delimiter of the path
* @return last object in relativePath
*/
private function path(root:DisplayObjectContainer,
relativePath:String, separator:String = ".") : DisplayObject {
var parts:Array = relativePath.split(separator);
var child:DisplayObject = root.getChildByName(parts[0]);
if (parts.length > 1 && child is DisplayObjectContainer) {
parts.shift();
var nextPath:String = parts.join(separator);
var nextRoot:DisplayObjectContainer = child as DisplayObjectContainer;
return path(nextRoot, nextPath, separator);
}
return child;
}