SWFLoader和Loader的区别

 

可以使用SWFLoader和Loader两个类来加载子应用程序,多数情况下我们使用SWFLoader。它是Loader的一个包装类,提供了很多附加功能,使加载子应用程序更简单。

SWFLoader有如下特征:

 

支持flex的样式和特效;而Loader类却不支持任何固有的样式和特效。

方便管理加载进度;如果使用Loader则首先要获取LoaderInfo引用。

 

是一个UIComponent组件。SWFLoader它自己管理了所有子显示对象,不需要添加多余的代码。

自动缩放显示内容的大小

 

可以加载Application以外的实现类,如果检测到不是一个Application,会自动进行处理。

可以处理不同的版本。Loader不支持加载不同的编译版本

 

当使用Loader加载不是受信任区域的swf时,必须提供一个遮罩来重新定位,否则它会显示在屏幕外面:

 

import flash.display.*;
import flash.net.URLRequest;
var rect:Shape = new Shape();
rect.graphics.beginFill(0xFFFFFF);
rect.graphics.drawRect(0, 0, 100, 100);
addChild(rect);
var ldr:Loader = new Loader();
ldr.mask = rect;
var url:String = "http://www.unknown.example.com/content.swf";
var urlReq:URLRequest = new URLRequest(url);
ldr.load(urlReq);
addChild(ldr);
 

 

原文:

 

 

You can use the SWFLoader and Loader classes to load sub-applications into a main application. In most circumstances, use the SWFLoader class. This class wraps the Loader class and provides additional functionality that makes it easier to use for loading sub-applications into main applications.

The SWFLoader control has the following features:

Supports Flex styles and effects; the Loader class does not have any inherent support for styles and effects.
Lets you monitor the progress of a load inherently (if you use the Loader class, you have to first get a reference to a LoaderInfo object).
Is a UIComponent. As a result, the SWFLoader control participates in the display list and adds children to the display list without having to write additional code.
Resizes and scales the contents automatically.
Does not require that the SWF file be an instance of the Application class, it just checks if an Application exists, and handles sizing differently.
Can be multi-versioned. The Loader class does not have built-in support for multi-versioning.
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
11
11-20 159

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值