0 Replies Latest reply on Jul 7, 2011 10:58 AM by Flex Rock

    Flex 4 styleManager loadStyleDeclarations fail

    Flex Rock Level 1

      Hi,

       

      I am starting to tinker with Flex 4 and I am having trouble trying to  load a style swf file.  I have a css file that looks like this

       

       

      @namespace s "library://ns.adobe.com/flex/spark";


      s|Application {
          background-color: red;
      }

       


      which I compiled to a css-based swf file.  The code I am using to load the swf is like this:

       

       

       

      // Called within a function

      var dispatcher : IEventDispatcher = FlexGlobals.topLevelApplication.styleManager.loadStyleDeclarations(th emeSwfUrl);
      dispatcher.addEventListener(StyleEvent.ERROR, onStyleError);
      dispatcher.addEventListener(StyleEvent.PROGRESS, onStyleProgress);
      dispatcher.addEventListener(StyleEvent.COMPLETE, onStyleComplete);

       

       

       

      private function onStyleError(event : StyleEvent) : void {
          trace("\tLoadThemeCommand.onIOError(event)");
          trace(event.errorText);
          Alert.show(event.errorText, "Theme Load Failure");
      }


      private function onStyleProgress(event : StyleEvent) : void {
          trace("\tLoadThemeCommand.onStyleProgress(event) " + event.bytesLoaded + " / " + event.bytesTotal);
      }


      private function onStyleComplete(event : StyleEvent) : void {
          trace("\tLoadThemeCommand.onLoadComplete(event)");
          trace('event.target: ' + (event.target));
          var dispatcher : IEventDispatcher = event.target as IEventDispatcher;
          trace('dispatcher: ' + (dispatcher));
          dispatcher.removeEventListener(StyleEvent.ERROR, onStyleError);
          dispatcher.removeEventListener(StyleEvent.PROGRESS, onStyleProgress);
          dispatcher.removeEventListener(StyleEvent.COMPLETE, onStyleComplete);
      }

       


      Its not dispacthing the StyleEvent.COMPLETE event, Because of this application gets hanged. It doesn't throw any error at all.

       

       

      Regards,

      Jayagopal.