I've never had any problems using this function to return an embedded asset as a bitmap which I can then manipulate or attach.

The getQualifiedSuperclassName if-statement is there because I have some assets with scale-9 enabled and they are returned as sprites, so I convert them first.

public static function getInterfaceAssetasBitmap (interfaceAsset:String):Bitmap {
        var assetClass:Class = getDefinitionByName(interfaceAsset) as Class;
        var returnBitmap:Bitmap;
        if ( getQualifiedSuperclassName(assetClass)=="mx.core::SpriteAsset") {  
      
                var asset:Sprite = new assetClass();
var bitmapData:BitmapData = new BitmapData(asset.width, asset.height, true, 0x00FFFFFF);
                bitmapData.draw(asset);
                returnBitmap.bitmapData=bitmapData;
} else if ( getQualifiedSuperclassName(assetClass) =="mx.core::BitmapAsset") {
                returnBitmap = new assetClass();
        }
        return(returnBitmap);
}       


Hope it helps,
Alan

_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to