带进度条加载模块
我的应用程序有几个模块,它们正在我的应用程序中加载。
<local:moduleloader url="Module1.swf" id="modulel" />
<local:moduleloader url="Module2.swf" id="module2" />
然后在加载每个模块时我会显示进度条。进度条显示但不会消失。它仍然位于应用程序的整个框架之上。模块加载器如下:(
另请注意,在 Flex 3 中同样有效,但我使用 Flex 4,而在 Fx 4 中则不然)
<mx:ModuleLoader xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns="*"
creationComplete="initTheModuleLoader()">
<fx:Script>
<![CDATA[
import mx.core.Application;
import mx.core.FlexGlobals;
private var ParentApp:* = FlexGlobals.topLevelApplication;
private var standin:DisplayObject;
private function initTheModuleLoader():void {
addEventListener("loading", onLoading);
addEventListener("progress", onProgress);
addEventListener("setup", onSetup);
addEventListener("ready", onReady);
addEventListener("error", onError);
standin = panel;
}
private function onUrlChanged(event:Event):void {
if (url == null) {
if (contains(standin))
removeChild(standin);
} else {
if (!contains(standin))
addChild(standin);
}
progress.indeterminate=true;
}
import mx.controls.Alert;
private function onLoading(event:Event):void {
//progress.label=languageXml.lastResult.progress.progressonLoading +' ' + url;//Loading module
progress.label = "Loading module" + ' ' + url;//Loading module
if (!contains(standin))
addChild(standin);
progress.indeterminate=true;
}
private function onProgress(event:Event):void {
//progress.label=languageXml.lastResult.progress.progressonProgress; //Loaded %3%%...
progress.label = "Loaded %3%%..."; //Loaded %3%%...
progress.indeterminate=false;
}
private function onSetup(event:Event):void {
//progress.label=String(languageXml.lastResult.progress.progressonSetup).replace('###',url)
progress.label = "on SetUp";
progress.indeterminate=false;
}
private function onReady(event:Event):void {
//progress.label= String(languageXml.lastResult.progress.progressonReady).replace('###',url);
progress.label = "onReady";
if (contains(standin))
removeChild(standin);
}
private function onError(event:Event):void {
//progress.label=languageXml.lastResult.progress.progressonError + " " + url;
progress.label = "Error";
}
private function onUnload(event:Event):void {
if (url == null) {
if (contains(standin))
removeChild(standin);
} else {
if (!contains(standin))
addChild(standin);
}
progress.indeterminate=true;
progress.label="Module " + url + " was unloaded!";
}
]]>
</fx:Script>
<mx:Panel id="panel" width="100%" borderStyle="none" >
<mx:ProgressBar width="100%" id="progress" source="{this}" />
</mx:Panel>
</mx:ModuleLoader>
有人可以帮忙吗?
My application has a couple of modules which am loading as thus in my application.
<local:moduleloader url="Module1.swf" id="modulel" />
<local:moduleloader url="Module2.swf" id="module2" />
Then while loading each module I am showing the progress bar. The progress bar shows but does not go away. It remains above the whole frame of the application. The module loader is as follows:
(Also note that in Flex 3 the same works, but am using Flex 4 and in Fx 4 it does not)
<mx:ModuleLoader xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns="*"
creationComplete="initTheModuleLoader()">
<fx:Script>
<![CDATA[
import mx.core.Application;
import mx.core.FlexGlobals;
private var ParentApp:* = FlexGlobals.topLevelApplication;
private var standin:DisplayObject;
private function initTheModuleLoader():void {
addEventListener("loading", onLoading);
addEventListener("progress", onProgress);
addEventListener("setup", onSetup);
addEventListener("ready", onReady);
addEventListener("error", onError);
standin = panel;
}
private function onUrlChanged(event:Event):void {
if (url == null) {
if (contains(standin))
removeChild(standin);
} else {
if (!contains(standin))
addChild(standin);
}
progress.indeterminate=true;
}
import mx.controls.Alert;
private function onLoading(event:Event):void {
//progress.label=languageXml.lastResult.progress.progressonLoading +' ' + url;//Loading module
progress.label = "Loading module" + ' ' + url;//Loading module
if (!contains(standin))
addChild(standin);
progress.indeterminate=true;
}
private function onProgress(event:Event):void {
//progress.label=languageXml.lastResult.progress.progressonProgress; //Loaded %3%%...
progress.label = "Loaded %3%%..."; //Loaded %3%%...
progress.indeterminate=false;
}
private function onSetup(event:Event):void {
//progress.label=String(languageXml.lastResult.progress.progressonSetup).replace('###',url)
progress.label = "on SetUp";
progress.indeterminate=false;
}
private function onReady(event:Event):void {
//progress.label= String(languageXml.lastResult.progress.progressonReady).replace('###',url);
progress.label = "onReady";
if (contains(standin))
removeChild(standin);
}
private function onError(event:Event):void {
//progress.label=languageXml.lastResult.progress.progressonError + " " + url;
progress.label = "Error";
}
private function onUnload(event:Event):void {
if (url == null) {
if (contains(standin))
removeChild(standin);
} else {
if (!contains(standin))
addChild(standin);
}
progress.indeterminate=true;
progress.label="Module " + url + " was unloaded!";
}
]]>
</fx:Script>
<mx:Panel id="panel" width="100%" borderStyle="none" >
<mx:ProgressBar width="100%" id="progress" source="{this}" />
</mx:Panel>
</mx:ModuleLoader>
Anybody could help on this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
发布评论
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
您的 onReady 处理程序会删除替身,但不会删除进度条。
Your onReady handler removes the standin, but not the progress bar.