我想访问已加载的SWF
文件的内容。我使用了以下代码,
function _browse(e:MouseEvent):void
{
loader.load(new URLRequest("artwork3.swf.swf"));
loader.contentLoaderInfo.addEventListener(Event.COMPLETE,loading);
target_clip.addChild(loader);
}
function loading(event:Event)
{
trace(target_clip.getChildAt(0));
trace(target_clip.getChildAt(1));
}
请帮帮我。
答案 0 :(得分:0)
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener( Event.COMPLETE, handleComplete );
var request:URLRequest = new URLRequest("artwork3.swf.swf");
loader.load(request);
protected function handleComplete(event:Event):void
{
DisplayObject loadedSwf = target_clip.addChild(event.currentTarget.content as DisplayObject) as DisplayObject;
//you can access variables from loaded swf
trace(loadedSwf.name);
}
答案 1 :(得分:0)
function _browse(e:MouseEvent):void
{
loader.load(new URLRequest("artwork3.swf.swf"));
loader.contentLoaderInfo.addEventListener(Event.COMPLETE,loading);
target_clip.addChild(loader);
}
function loading(event:Event)
{
var myLoadedSwf:MovieClip = loader.content as MovieClip;
trace(myLoadedSwf.getChildAt(0));
trace(myLoadedSwf.getChildAt(1));
//trace(target_clip.getChildAt(0));
//trace(target_clip.getChildAt(1));
}
答案 2 :(得分:0)
尝试使用MovieClip(loader.content)
代替target_clip,
function _browse(e:MouseEvent):void
{
loader.load(new URLRequest("artwork3.swf.swf"));
loader.contentLoaderInfo.addEventListener(Event.COMPLETE,loading);
target_clip.addChild(loader);
}
function loading(event:Event)
{
trace(MovieClip(loader.content).getChildAt(0));
trace(MovieClip(loader.content).getChildAt(1));
}
祝你好运。