我不確定我完全理解你的問題,但它聽起來像你想以類似於創建類的新實例的方式獲取此位圖數據的副本。如果是這樣的話,你可以做這樣的事情:
//grab the name of the asset as a string
var bitmapDataAssetName:String = products[i].producticon+"Data";
//get the asset definition from the SWC
var CustomBitmapDataClass:Class = getDefinitionByName(bitmapDataAssetName) as Class;
//store it in an associative array or dictionary for use later
var myBitmaps:Array = [];
myBitmaps[bitmapDataAssetName] = CustomBitmapDataClass;
//then instantiate new bitmaps from the class definition that's stored in your array
var testBitmapData:BitmapData = new (myBitmaps[bitmapDataAssetName] as Class)() as BitmapData;
所以,在實際使用的情況下,你的符號定義陣列將是對一些BitmapManager類或某事的一個成員變量。然後,如果你想讓它在應用程序的任何地方訪問,只是讓一個單身,和急 - 你可以從你的SWC實例化一個新的庫資產的任何地方,你有這樣的調用需要它:
var localBitmapData:BitmapData = new (BitmapManager.instance.definitions[theNameOfTheBitmapIWant] as Class)() as BitmapData;
或者,更好的方式來做到這一點會是一個方法添加到BitmapManager像
public function getBitmapAsset(assetName:String):BitmapData {
var symbolDefinition:Class = myBitmaps[bitmapDataAssetName] as Class;
return new symbolDefinition() as BitmapData;
}
所以你也可以把它像這樣:
var localBitmapData:BitmapData = BitmapManager.instance.getBitmapAsset("theNameOfTheBitmapIWant");
希望幫助(如果那是你開始的問題):P
來源
2011-06-02 00:05:43
Ian