5 Replies Latest reply on Oct 29, 2009 7:20 AM by chandu3107

    loading fonts with stylemanager

    ckisthebest Level 1

      Hi all,

       

      I am have embedded fonts with css and compiled css to swf.

       

      Each font I am loading with StlyeManager.load methods. When each loads swf it renders whole application.

       

      any suggestion what to do?

       

      Should i use module loader ?

       

      Please help me.

       

      Thanks,

      -CK

        • 1. Re: loading fonts with stylemanager
          Jerry62712 Level 1

          Are you saying that it works and you get the new CSS, but you don't want to have the whole SWF rendered?  Is it because of some movie running on it?  I swap CSS files and have noticed no problem other than Flex/Flash doesn't render everything such that the vertical height of containers isn't increased enough to hold the new sized font.

          • 2. Re: loading fonts with stylemanager
            ckisthebest Level 1

            yes it works, but when i load a css as swf it shows like whole application is rendered again.

             

            any idea? can i give size to css? or can i load fonts swf with modules?

            • 3. Re: loading fonts with stylemanager
              Jerry62712 Level 1

              All the text or any CSS aware object should render again as you have changed the attributes of that text by loading a new CSS file.  That's the reason you do it.  I swap CSS files to change the size of the font or to change the background color to get a higher (and ugly) contrast.  That's how we address the 508 issues.

               

              What part of the application do you want to ignore CSS?

              • 4. Re: loading fonts with stylemanager
                ckisthebest Level 1

                For each font i have separate css. So when i change a font a css is loaded and application is rendered.

                 

                I want only text rendered.

                 

                How to do it?

                • 5. Re: loading fonts with stylemanager
                  chandu3107 Level 2

                  Load fonts from module. Below is the code for it.

                   

                   

                  var fontPath:string = "http://yourserverpath/Arial.swf";
                  //create new ulr request
                  var request:URLRequest = new URLRequest(fontPath);
                  //create new module loader

                  moduleLoader = new ModuleLoader();
                  moduleLoader.addEventListener(ModuleEvent.READY,onReady);
                  //create new urlloader
                  loader = new URLLoader();

                  loader.addEventListener(Event.COMPLETE,loadComplete);
                  loader.dataFormat = URLLoaderDataFormat.BINARY;
                  loader.load(request);


                  //create listner for loader load complete event

                  private function loadComplete(event:Event):void
                  {
                      //remove complete event listener from urlloader
                      loader.removeEventListener(Event.COMPLETE,loadComplete);
                      var moduleBytes:ByteArray = ByteArray(URLLoader(event.target).data);
                      moduleLoader.loadModule(fontPath,moduleBytes);
                      loader=null;
                  }

                  //module ready listner. module is loaded

                  private function onReady(event:ModuleEvent):void
                  {
                       //Arial.swf is loaded you can use it
                       var textArea:TextArea=new TextArea();
                       textArea.text = "This is Arial Font";
                       textArea.rotation = 45;
                       textArea.setStyle("fontFamily","Arial");
                       this.addChild(textArea);
                  }