• 【设为首页】
  • 【收藏闪客居】
当前位置:主页>FLASH AS 编程>AS基础篇>AS 3.0>文章内容
  • flash AS3 外部加载的一些问题
  • 来源: 作者: 2007-06-02 【

在AS2中加载外部swf文件一般都用MovieClipLoader对象,在as3中则需要采用Loader比较方便。Loader继承

DisplayObject,因此,你可以直接在一个DisplayObject中采用addChild方法加载进来:

var loader:Loader = new Loader();
this.addChild(loader);

但是,这样你加载进来的是一个Loader,而不是Loader对象Load进来的swf,因此,你需要采用这样的方式:

var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
loader.load(new URLRequest("lib.swf"));
function completeHandler(event:Event){
var _content:DisplayObject = event.target.content;
this.addChild(loader);
}

此外,需要注意,你无法直接监听loader对象来获取文件是否加载完毕。需要采用loader.contentLoaderInfo.




上一篇:flash as3来做三角计算   下一篇:使用flash as3生成gif动画
  • 用户名:新注册) 密码: 匿名评论
  • 评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规)

Copyright © 2006-2008 flashas.net All Rights Reserved.
网站内容咨询: admin#flashas.net (#为@) 联系QQ:40777822 浙ICP备06033001号
(本网站最佳浏览解析度为1024*768, 建议使用IE 6.0或以上版本浏览器。)