Posts Tagged ‘XML’

  • Adobe说:

    “You can use the [Embed] metadata tag to import
    JPEG, GIF, PNG, SVG, SWF, TTF, and MP3 files.”
    

    但我们可以通过下面的方法将XML也作为资源嵌入进SWF中

    package example
    {
    import mx.core.ByteArrayAsset;
    
    public final class Config
    {
    [Embed("config.xml", mimeType="application/octet-stream")]
    private static const Config:Class;
    
    public static function getConfig() : XML
    {
    var ba:ByteArrayAsset = ByteArrayAsset( new Config()) ;
    var xml:XML = new XML( ba.readUTFBytes( ba.length ) );
    
    return xml;
    }
    }
    }

    作者已经把此方法封装成了XMLAsset类,原文见这里

    http://www.ericfeminella.com/blog/2008/07/27/xmlasset-api/