4 Replies Latest reply on Nov 20, 2009 5:08 AM by sebastiantoro84

    how to dispatch an event from the application to the preloader

    sebastiantoro84 Level 1

      HI everyone

                       I've been searching everywhere on the net, and as far as it goes I gotten no answer for this. When the application hit the preinitialize phase, I'm calling the loadStyle method. As you can see I will hold the CreationComplete event until I the swf is ready. What I want to do, is to have a second loading bar in the preloader (no problem here) to show the progress of the swf downloaded, hence the StyleEvent.PROGRESS event. I would like to know how can I dispatch that event to the preloader?


                    import mx.events.StyleEvent;
                  import mx.styles.StyleManager;
                  private function loadStyle():void
                          var eventDispatcher:IEventDispatcher = StyleManager.loadStyleDeclarations("cl/elmelej/mangiare/estilo/estilo.swf");
                          eventDispatcher.addEventListener(StyleEvent.COMPLETE, completeHandler);
                  private function completeHandler(event:StyleEvent):void
                          super.initialized = true;
                  private function progreso(event:StyleEvent):void
                  override public function set initialized(value:Boolean):void
                      // Hold off until the Runtime CSS SWF is done loading.


      virtual public function set preloader(value:Sprite):void
                  _preloader = value;
                  value.addEventListener(ProgressEvent.PROGRESS, progressHandler);   
                  value.addEventListener(Event.COMPLETE, completeHandler);
                  value.addEventListener(StyleEvent.PROGRESS, progressHandlerCSS);  


                  value.addEventListener(FlexEvent.INIT_PROGRESS, initProgressHandler);
                  value.addEventListener(FlexEvent.INIT_COMPLETE, initCompleteHandler);


      As you can see, the preloader is listening to StyleEvent.PROGRESS  events, but I cant dispatch that event to the preloader so that it can react to it. I hope you can help me. Thanks for your time and help