这个功能很使用哦!我研究了好一会儿,根据网上一篇文章,实践出来的!
打开LoadingItem.as文件,加入方法!
public function getContent(swfcontent:String):*
{
return null;
}
{
return null;
}
打开ImageItem.as文件,增加一属性public var swfContent:Object; 修改onCompleteHandler方法
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
override public function onCompleteHandler(evt : Event):void
{
try
{
_content = loader.content;
swfContent = loader.content;
super.onCompleteHandler(evt);
}
catch (e:SecurityError)
{
_content = loader;
super.onCompleteHandler(evt);
}
}
{
try
{
_content = loader.content;
swfContent = loader.content;
super.onCompleteHandler(evt);
}
catch (e:SecurityError)
{
_content = loader;
super.onCompleteHandler(evt);
}
}
在ImageItem.as文件加入,getContent方法,达到复写的目的!
override public function getContent(swfcontent:String):*
{
try
{
return swfContent.getChildByName(swfcontent) as MovieClip;
}
catch (err:Error)
{
return null;
}
}
{
try
{
return swfContent.getChildByName(swfcontent) as MovieClip;
}
catch (err:Error)
{
return null;
}
}
前面在main主文档调用的时候,初始化一个
var bulkLoader:BulkLoader = new BulkLoader("main ...");
var MC:MovieClip = bulkLoader.get("ban.swf").getContent("MC") as MovieClip;
trace(MC.totalFrames);//打印舞台上一个实例对象MC的总帧数
this.addChild(MC);
MC.gotoAndPlay(1);
ban.swf是要加载的外部swf文件.
此外还可以加入应用程序域!
原文:http://junnan.org/blog/?p=1014