4 Replies Latest reply on Aug 24, 2007 7:00 AM by levancho

    Force App to Load XML file completely before any component initializes

    levancho Level 3
      I have changed the way my app is configured from properties file approach to xml file approach ,so I moved all my configurations into xml that way I can change values on the fly and dont have to recompile whole application.
      , but now I hit the problem, Things are breaking everywhere because application is getting initialized before xml finishes loading (Before with properties file it was working fine I guess preloading properties file is built into framework )
      my question is: is it possible to somehow force application not to pass that progress bar until my xml is not loaded completely and until it does not fire READY event? I want application not to even initialize , meaning not to start creating components until that file is not loaded. and maybe even break if it does not load ?
      has anyone done this before? if so please give me advice
      Kind Regards.
        • 1. Re: Force App to Load XML file completely before any component initializes
          Are you doing everything in (*cough*) mxml, or in AS 3?

          In AS3, you would just load all the xml files first, set handlers on their complete events, and in each handler check if they've all loaded. if so, call a method that builds the rest of the app.

          In mxml I don't know what to do- does the mxml load right away? I avoid mxml completely.



          • 2. Re: Force App to Load XML file completely before any component initializes
            brado77 Level 1
            TankMan,

            Not to hijack this thread, but pertaining to your "I avoid MXML completely", I just recently posted a question regarding coding in AS vs. MXML, and since you avoid MXML, I wondered if you might expound a little more on why. Here's the thread which refers to this...your thoughts are desired!

            http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=60&catid=585&threadid =1295337&enterthread=y

            Thanks.....

            Brad
            • 3. Re: Force App to Load XML file completely before any component initializes
              peterent Level 2
              Try something like this:

              Put your application into another file, say based on Canvas. This would contain pretty much everything in your app. In the main app you will load the XML and in the result event handler cause this new component to become visible. You have a number of choices here. In no particular order:

              Put the main component in a state with the base state empty or it could have something that says "Loading...". When the event handler is invoked, set the currentState. This will make your main component visible. You can then use a transition to make it appear (zoom in, slide in, etc).

              In the result event handler just create the main component and add it to the display list:
              var main:MainComponent = new MainComponent();
              addChild(main);

              You could put your main component into a Module and then when the result event handler is called, load the module.

              That should give you some directions.
              • 4. Re: Force App to Load XML file completely before any component initializes
                levancho Level 3
                I going to go with peters suggestion, only use viewStack instead of states,
                Befor I came up with a nasty hack that kind of worked before :

                private function LoadInterupt(): void{
                var counter: int = 0;
                while(!this.isRegistered && counter<100) {
                counter++;
                }

                if(this.isRegistered) {
                parseConfiguration();
                }else {
                Application.application.callLater(LoadInterupt);
                }
                }

                but now I have good advise, let me try that .(the only problem that I think its gonna give is that I have a nasty way of referencing things by Application.application.SomeComponentId etc . so now I guess all that is going to break. :(