Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache flex 作为代码从预加载程序调用应用程序中的函数_Apache Flex_Flex4_Flex4.5_Flexbuilder - Fatal编程技术网

Apache flex 作为代码从预加载程序调用应用程序中的函数

Apache flex 作为代码从预加载程序调用应用程序中的函数,apache-flex,flex4,flex4.5,flexbuilder,Apache Flex,Flex4,Flex4.5,Flexbuilder,我想在调度完整事件之前,从actionscript中的自定义预加载程序代码调用main flex应用程序中的函数。 我还想知道如何从应用程序调用预加载程序代码中的函数 谢谢因此,在preload init方法中,您可以使用以下行获取应用程序: parentApplication = event.currentTarget.loaderInfo.content.application; 我们的预加载程序实现了一个名为IPreloader的自定义接口,我们的应用程序实现了一个名为I

我想在调度完整事件之前,从actionscript中的自定义预加载程序代码调用main flex应用程序中的函数。 我还想知道如何从应用程序调用预加载程序代码中的函数


谢谢

因此,在preload init方法中,您可以使用以下行获取应用程序:

        parentApplication = event.currentTarget.loaderInfo.content.application;
我们的预加载程序实现了一个名为IPreloader的自定义接口,我们的应用程序实现了一个名为IPreloaderApp的自定义接口,IPreloader的定义如下:

package com.roundarch.adapt.preloader
{
    import mx.preloaders.IPreloaderDisplay;

    public interface IPreloader extends IPreloaderDisplay
    {
        /**
         * Setting this will update the preloader's percentage bar or graphic.
         */
        function set percentage(value:Number):void;
        function get percentage():Number;

        /**
         * Sets the status (if available) on the preloader.
         */
        function set status(value:String):void;

        /**
         * This will communicate to the preloader that loading of all application
         * properties is complete.
         */
        function loadingComplete():void;

        /**
         * This will tell the preloader that there has been an error loading the application.
         *
         * The preloader will probably want to display this error message in a nice display to
         * the user.
         *
         * @param errorString The error message to display.
         * @param fatal If true, the preloader should act as if the application will not run perhaps
         * by notifying the user that they cannot continue.
         * @return Should return true if the error was properly handled.
         */
        function displayError(errorString:String, fatal:Boolean=false):Boolean;

        /**
         * Returns true if this IPreloader implementation can handle displaying loading
         * errors through the error(...) method. If false, the implementing application will
         * need to notify the user of any errors itself.
         */
        function get canDisplayErrors():Boolean;
    }
}
对于IPreloaderApp

package com.roundarch.adapt.preloader
{

    /**
     * Any application which uses an IPreloader as its preloader will be
     * required to implement this interface or throw an error.
     */
    public interface IPreloaderApp
    {
        /**
         * Once the application has loaded and initialized, this method will be called on the
         * application and the preloader will be passed in so the app can make updates to it.
         */
        function preloaderInit(preloader:IPreloader):void;
    }
}
另外需要注意的是,如果应用程序添加在预加载程序后面,而不是默认行为前面,那么您将不会看到应用程序弹出的警报,因为它们将位于预加载程序后面,因此您需要切换顺序。下面是我们用来解决这个问题的一些代码:

    private var removedOnce : Boolean;

    //When the Preloader class instance (this things parent) is removed from it's parent
    //add this to the stage, allows us to dispatch the complete event at the corret time
    //allowing the SystemManager to add the application to the stage and adding this at
    //index 0 to allow pop-ups to show over it.
    private function parentRemoved(event : Event) : void
    {
        if (!removedOnce)
        {
            removedOnce = true;

            stage.addChildAt(this, 0);
            ToolTipManager.enabled = false;
        }
    }
在预加载程序init处理程序中设置了parentApplication之后,如本文顶部所示,我们添加了一个处理程序,以捕获SystemManager删除预加载程序并重新添加它,没有可见的闪烁

        //Lets the system manager know to add the application to the stage
        //this will also remove the preloader for this reason I'm listening for the removal
        //then adding the preloader to the stage again
        parent.addEventListener(Event.REMOVED, parentRemoved);
        dispatchEvent(new Event(Event.COMPLETE));

另一件需要注意的事情是,您不想用任何Flex类污染预加载程序代码,如果您包含框架中的内容,您将不得不在预加载程序开始之前将整个框架加载到内存中,这可能会很繁重。

请共享预加载程序的代码。您的问题描述不清楚无论您的具体问题是什么,您可能都应该重新考虑您的体系结构:预加载程序的本质是在应用程序准备就绪之前执行操作,并在应用程序准备就绪时消失。你的两个问题都与这个想法相矛盾。我们实际上是这样做的。虽然在某些情况下这可能看起来是矛盾的——在我们的例子中,我们加载主swf文件,然后在启动时执行一系列额外的数据请求,因为这些请求可能需要一段时间——我们保持预加载程序运行,并使其显示有关应用程序的提示,以保持其信息性和娱乐性。基本上,我们把一个方法放在预加载程序中,当应用程序完成时,它会通过这个方法将自己传递给预加载程序,然后预加载程序又通过一个方法将自己传递回应用程序,从而建立起沟通的桥梁。好了,现在我明白你的意思了。谢谢你的帮助。嘿,我不想完整地发布我的代码,因为它是由我们公司的其他人编写的,我也不想放弃农场,但我会看看是否可以将它简化为一个简化版本,只包含你需要开始并发布的部分。