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.

你可能感兴趣的:(.net,Flex,Flash)