7 Replies Latest reply on Jun 1, 2009 12:54 PM by Flex harUI

    Can you explain me the loading process?

    IlyaG Level 1

      This is my application: http://gazman.000space.com. If you will try to enter it now, you will see two loading bars one that is build in the application, that loading swf file, and one I made, that loading images that the application will use(I am just using the flash.display.Loader with URLRequest for the images).

      Later after my loading bar is 100% comes another build in loading for another swf file when I redirect the page, even that I loaded it before(with the images).

       

      Is there any way to create a main loading component that will do all the loading tasks?

        • 1. Re: Can you explain me the loading process?
          Flex harUI Adobe Employee

          You can turn off the built-in by setting usePreloader="false" in the mx:Application tag

           

          Then, for sub-applications, you can load them using SWFLoader and wire them up to an mx:ProgressBar if you want since they report bytesTotal and bytesLoaded

           

          Alex Harui

          Flex SDK Developer

          Adobe Systems Inc.

          Blog: http://blogs.adobe.com/aharui

          1 person found this helpful
          • 2. Re: Can you explain me the loading process?
            IlyaG Level 1

            I think this is it just can you tell me where do I add the complete event to know when my loading is done? Some how I can't find it.

            • 3. Re: Can you explain me the loading process?
              Flex harUI Adobe Employee

              SWFLoader will dispatch a COMPLETE event.  If you are using flash.display.Loader, you have to listen to the contentLoaderInfo instead

               

              Alex Harui

              Flex SDK Developer

              Adobe Systems Inc.

              Blog: http://blogs.adobe.com/aharui

              1 person found this helpful
              • 4. Re: Can you explain me the loading process?
                IlyaG Level 1

                So who is the listener for this event?

                • 5. Re: Can you explain me the loading process?
                  Flex harUI Adobe Employee

                  Whatever code needs to react to Complete and know that it is done.  Maybe show some code so we understand what you are trying to do

                   

                  Alex Harui

                  Flex SDK Developer

                  Adobe Systems Inc.

                  Blog: http://blogs.adobe.com/aharui

                  • 6. Re: Can you explain me the loading process?
                    IlyaG Level 1

                    The most simple thing. Just load all the images and files that my application will use, so there will not be any loading in the middle of the application. This is what I got so far:

                     

                     

                    <mx:Script>
                            <![CDATA[
                                import mx.events.FlexEvent;
                                import mx.controls.SWFLoader;
                                import mx.controls.Image;

                     

                    private var totalNum:int,curentNum:int;

                     

                    private function init():void
                                {
                                    import flash.display.Loader;
                                   
                                    totalNum=0;
                                    curentNum=0;
                                   
                                    progressBar.label="Loadin 0%";
                                   
                                    var ldr:Loader=new Loader();
                                    var SWFLdr:SWFLoader=new SWFLoader();

                                    var urlReq:URLRequest=new URLRequest("images1");

                                    ldr.load(urlReq);
                                    ldr.contentLoaderInfo.addEventListener(Event.COMPLETE,loaded);
                                    totalNum++;
                                   
                                    urlReq=new URLRequest("images2");
                                    ldr=new Loader();
                                    ldr.load(urlReq);
                                    ldr.contentLoaderInfo.addEventListener(Event.COMPLETE,loaded);
                                    totalNum++;
                                   
                                   
                                    urlReq=new URLRequest("images3");
                                    ldr=new Loader();
                                    ldr.load(urlReq);
                                    ldr.contentLoaderInfo.addEventListener(Event.COMPLETE,loaded);
                                    totalNum++;
                                   
                                    urlReq=new URLRequest("game.swf");
                                    SWFLdr.load(urlReq);
                                    totalNum++;
                                   
                                    curentNum=totalNum;
                                   
                                   
                                }
                               
                                private function loaded(e:Event):void
                                {
                                    var ldr:Loader;
                                    var urlReq:URLRequest;
                                   
                                    curentNum--;
                                    progressBar.setProgress((1-curentNum/totalNum)*100,100);
                                    progressBar.label="Loading "+int((1-curentNum/totalNum)*100)+"%";
                                   
                                    if (curentNum==0)
                                    {
                                       Alert.show("Well done");
                                    }   
                                   
                                               
                               }
                            ]]>
                        </mx:Script>
                       
                        <mx:ProgressBar themeColor="#F20D7A" horizontalCenter="0" verticalCenter="99" id="progressBar" maximum="100" minimum="0" labelPlacement="bottom"
                                        direction="right" mode="manual">
                        </mx:ProgressBar>

                    ****************************************************************************************** *************************************************************************

                     

                     

                    I would like that loaded() will get the COMPLETE evetn of  SWFLdr.load(urlReq).

                    If it's yet not clear just visit the site, so you e able to see what I am talking about.

                    • 7. Re: Can you explain me the loading process?
                      Flex harUI Adobe Employee

                      Hi Rick,

                       

                      Sorry about that, I'm incredibly new to this and in desperate need to find a solution- and fast! Might you be able to help me? (PLEASE) I clicked the link and it just directed me back to my previous post. Once again, I'm a rookie in need of guidance!

                       

                      Thanks,

                       

                      Ashli

                       

                       

                      --

                      Ashli Townsend

                      Fashion Blog Editor

                      Public Relations | Marketing

                      Phone: 323.937.1351

                      Fax: 323.658.1903

                      www.barnettellman.com.blogspot.com

                      www.barnettellman.com

                      8484 Wilshire Blvd | Suite 242 | Beverly Hills | 90211