用xml配置加载cs中为ActionScript导出的类

private var swfLoader:Loader;
private function loadSwf():void
{
// TODO Auto Generated method stub
swfLoader = new Loader();
swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,swfLoadCompleteHandler);
swfLoader.load(new URLRequest("music.swf"));//music.swf是把cs中所有声音类放在music.fla中导出的swf
}

protected function swfLoadCompleteHandler(event:Event):void
{
// TODO Auto-generated method stub
swfLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE,swfLoadCompleteHandler);
var swfInfo:LoaderInfo = LoaderInfo(event.target);
var i:int = 0;
var len:int = picList.length;
for(i;i<len;i++)
{
var picVo:PicVo = PicVo(picList[i]);
picVo.swfInfo = swfInfo;
var soundClass:Class = picVo.swfInfo.applicationDomain.getDefinition(picVo.className) as Class;//picVo.className是cs中定义好的类名解析xml后存在PicVo类中
var sound:Sound = new soundClass();
picVo.sound = sound;
}

}

posted on 2013-03-22 10:23  橙小风  阅读(250)  评论(0编辑  收藏  举报