带进度条加载模块

发布于 11-30 05:34 字数 3837 浏览 1 评论 0原文

我的应用程序有几个模块,它们正在我的应用程序中加载。

<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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

怕倦2024-12-07 05:34:10

您的 onReady 处理程序会删除替身,但不会删除进度条。

Your onReady handler removes the standin, but not the progress bar.

轻拂→两袖风尘2024-12-07 05:34:10

我得到了它。

首先,在 Flex 3 中,将 InitModuleLoader 函数放在creationComplete 中是可行的,但在 Flex 4 中,必须在初始化中指定该方法。

其次,它在 Flex 4 中不显示(在 Flex 3 中显示),因此我将 mx:Panel 替换为 mx:HBox 或 s:Group

就这样,它就可以工作了。

但正如 J_A_X 上面建议的那样,最好使用 Fx 4.5,因为它有一个可换肤的新 moduleLoader,这可能会使其变得非常酷。

I got it.

Firstly in Flex 3 putting the InitModuleLoader function in creationComplete works but in Flex 4 this method has to be specified in initialize.

Secondly the does not show in Flex 4 (it does in Flex 3), so I replaced mx:Panel by mx:HBox or s:Group

Thats all and it work.

But as J_A_X suggested above its better to use the Fx 4.5 as it has a new moduleLoader thats skinnable which might render it pretty cool.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文