flex 字体加载方式4

 

<?xml version="1.0"

 encoding="utf-8"

?>




<!-- http://blog.flexexamples.com/2007/10/25/embedding-fonts-from-a-flash-swf-file-into-a-flex-application/ -->




<mx:Application

 name="Embed_fonts_test"




        xmlns:mx="http://www.adobe.com/2006/mxml"




        layout="vertical"




        verticalAlign="middle"




        backgroundColor="white"




        applicationComplete="init()"

>




 
    <mx:Script>


        <![CDATA[


            private function init():void {


                var appInfo:LoaderInfo = Application.application.loaderInfo;


                /* Just grab the filename from the SWF URL. */


                var fileName:String = (appInfo.url).split("/").pop();


                /* Convert bytes to kilobytes. */


                var kbTotal:String = (appInfo.bytesTotal / 1024).toFixed(2);


                info.text = fileName + " (" + kbTotal + "kb)";


            }


        ]]>


    </mx:Script>


 
    <mx:Style

>




        @font-face{
            src: url('./fonts/fromFlash.swf');
            fontFamily: "Myriad Web Pro";
        }
 
        .myriadWebProFromSWF {
            fontFamily: "Myriad Web Pro";
            fontSize: 24;
        }
    </mx:Style

>




 
    <mx:ApplicationControlBar

 dock="true"

>




        <mx:Label

 id="info"

 />




    </mx:ApplicationControlBar

>




 
    <mx:Text

 styleName="myriadWebProFromSWF"

>




        <mx:text

>



The quick brown fox jumped over the lazy dog.</mx:text

>




    </mx:Text

>




 
</mx:Application

>




另外一种加载字体方式:
<?xml version="1.0"
 encoding="utf-8"
?>


<!-- http://blog.flexexamples.com/2007/10/25/embedding-fonts-from-a-flash-swf-file-into-a-flex-application/ -->


<mx:Application
 name="Embed_fonts_test"


        xmlns:mx="http://www.adobe.com/2006/mxml"


        layout="vertical"


        verticalAlign="middle"


        backgroundColor="white"


        applicationComplete="init()"
>


 
    <mx:Script>

        <![CDATA[

            [Embed(source="./fonts/fromFlash.swf", fontName="Myriad Web Pro")]

            private var myriadWebProRegular:Class;

 
            private function init():void {

                var appInfo:LoaderInfo = Application.application.loaderInfo;

                /* Just grab the filename from the SWF URL. */

                var fileName:String = (appInfo.url).split("/").pop();

                /* Convert bytes to kilobytes. */

                var kbTotal:String = (appInfo.bytesTotal / 1024).toFixed(2);

                info.text = fileName + " (" + kbTotal + "kb)";

            }

        ]]>

    </mx:Script>

 
    <mx:Style
>


        .myriadWebProFromSWF {
            fontFamily: "Myriad Web Pro";
            fontSize: 24;
        }
    </mx:Style
>


 
    <mx:ApplicationControlBar
 dock="true"
>


        <mx:Label
 id="info"
 />


    </mx:ApplicationControlBar
>


 
    <mx:Text
 styleName="myriadWebProFromSWF"
>


        <mx:text
>

The quick brown fox jumped over the lazy dog.</mx:text
>


    </mx:Text
>


 
</mx:Application
>

你可能感兴趣的:(Web,xml,Flex,Flash,Adobe)