我们知道Flex程序启动之初,能够默认加载RSL。此外还会默认加载些什么呢?
通过对Flex框架源代码的分析,可以得知Flex框架默认加载三种类型的对象:
(1)。经过Adobe数字签名的跨域RSL
(2)。我们自定义的RSL
(3)。国际化应用中使用到的ResourceModule,其文件扩展名也是swf。
>>源代码佐证:
下面代码中红色字体代表两个数组,分别保存有RSL列表和ResourceModule列表。这两个列表作为参数被传入到进度条实例中,由进度条循环这两个列表来加载相应内容。
(注:灰色背景加删除线的内容是为了突出标题内容而作的视觉处理)
代码源文件:mx.managers.SystemManager.as
/**
* @private
* Creates an instance of the preloader, adds it as a child, and runs it.
* This is needed by Flash Builder. Do not modify this function.
*/
mx_internal function initialize():void
{
var runtimeDPIProviderClass:Class = info()["runtimeDPIProvider"] as Class;
if (runtimeDPIProviderClass)
Singleton.registerClass("mx.core::RuntimeDPIProvider", runtimeDPIProviderClass);
if (isStageRoot)
{
// TODO: Finalize scaling behavior
Stage_resizeHandler();
// _width = stage.stageWidth;
// _height = stage.stageHeight;
}
else
{
_width = loaderInfo.width;
_height = loaderInfo.height;
}
// Create an instance of the preloader and add it to the stage
preloader = new Preloader();
// Listen for preloader events
// preloader notifes when it is ok to go to frame2
preloader.addEventListener(FlexEvent.PRELOADER_DOC_FRAME_READY,
preloader_preloaderDocFrameReadyHandler);
// wait for a complete event. This gives the preloader
// a chance to load resource modules before
// everything really gets kicked off
preloader.addEventListener(Event.COMPLETE,
preloader_completeHandler);
// when the app is fully backed remove the preloader and show the app
preloader.addEventListener(FlexEvent.PRELOADER_DONE,
preloader_preloaderDoneHandler);
preloader.addEventListener(RSLEvent.RSL_COMPLETE,
preloader_rslCompleteHandler);
// Add the preloader as a child. Use backing variable because when loaded
// we redirect public API to parent systemmanager
if (!_popUpChildren)
{
_popUpChildren = new SystemChildrenList(
this, new QName(mx_internal, "noTopMostIndex"), new QName(mx_internal, "topMostIndex"));
}
_popUpChildren.addChild(preloader);
// 取出跨域RSL、自定义的RSL
var rsls:Array = info()["rsls"];
var cdRsls:Array = info()["cdRsls"];
var usePreloader:Boolean = true;
if (info()["usePreloader"] != undefined)
usePreloader = info()["usePreloader"];
var preloaderDisplayClass:Class = info()["preloader"] as Class;
// 定义RSL列表
var rslItemList:Array = [];
var n:int;
var i:int;
//编辑RSL列表,把Adobe数字签名的跨域RSL加入列表
if (cdRsls && cdRsls.length > 0)
{
if (isTopLevel())
rslDataList = cdRsls;
else
rslDataList = LoaderUtil.processRequiredRSLs(this, cdRsls);
var normalizedURL:String = LoaderUtil.normalizeURL(this.loaderInfo);
var crossDomainRSLItem:Class = Class(getDefinitionByName("mx.core::CrossDomainRSLItem"));
n = rslDataList.length;
for (i = 0; i < n; i++)
{
var rslWithFailovers:Array = rslDataList[i];
// If crossDomainRSLItem is null, then this is a compiler error. It should not be null.
var cdNode:Object = new crossDomainRSLItem(rslWithFailovers,
normalizedURL,
this);
rslItemList.push(cdNode);
}
}
//编辑RSL列表,把我们自定义的RSL加入列表
// Append RSL information in the RSL list.
if (rsls != null && rsls.length > 0)
{
if (rslDataList == null)
rslDataList = [];
if (normalizedURL == null)
normalizedURL = LoaderUtil.normalizeURL(this.loaderInfo);
n = rsls.length;
for (i = 0; i < n; i++)
{
var node:RSLItem = new RSLItem(rsls[i].url,
normalizedURL,
this);
rslItemList.push(node);
rslDataList.push([new RSLData(rsls[i].url, null, null, null,
false, false, "current")]);
}
}
//定义并编辑ResourceModule列表
// They can also specify a comma-separated list of URLs
// for resource modules to be preloaded during frame 1.
var resourceModuleURLList:String =
loaderInfo.parameters["resourceModuleURLs"];
var resourceModuleURLs:Array =
resourceModuleURLList ? resourceModuleURLList.split(",") : null;
var domain:ApplicationDomain =
!topLevel && parent is Loader ?
Loader(parent).contentLoaderInfo.applicationDomain :
info()["currentDomain"] as ApplicationDomain;
//把RSL列表和ResourceModule列表传入进度条实例,供其使用
// Initialize the preloader.
preloader.initialize(
usePreloader,
preloaderDisplayClass,
preloaderBackgroundColor,
preloaderBackgroundAlpha,
preloaderBackgroundImage,
preloaderBackgroundSize,
isStageRoot ? stage.stageWidth : loaderInfo.width,
isStageRoot ? stage.stageHeight : loaderInfo.height,
null,
null,
rslItemList,
resourceModuleURLs,
domain);
}