Цитата:
То потом можешь у ассет менеджера получить ее через
 Код AS3:
getBitmap("some_image");
|
Расширил функцию для того, чтобы можно было получать так же изображения из атласа. В сеттере сохраняемых битмап для ассетменеджера указываем не имя текстуры, а имя атласа. При получении битмапа через функцию getBitmap вторым параметром указываем имя атласа.

Код AS3:
public function getBitmap( textureName : String, atlasName : String = null ) : Bitmap
{
// case of simple texture
if ( !atlasName )
{
return mBitmaps[textureName];
}
// case of texture in atlas
var textureAtlas : TextureAtlas = getTextureAtlas( atlasName );
var textureRegion : Rectangle = textureAtlas.getRegion( textureName );
var textureFrame : Rectangle = textureAtlas.getFrame( textureName );
if ( textureFrame )
{
var textureWidth : uint = textureFrame.width;
var textureHeight : uint = textureFrame.height;
var regionLeft : uint = -textureFrame.x;
var regionTop : uint = -textureFrame.y;
var regionWidth : uint = textureRegion.width;
var regionHeight : uint = textureRegion.height;
}
else
{
textureWidth = textureRegion.width;
textureHeight = textureRegion.height;
regionLeft = 0;
regionTop = 0;
regionWidth = textureRegion.width;
regionHeight = textureRegion.height;
}
var bitmapData : BitmapData = new BitmapData( textureWidth, textureHeight, true, 0x00000000 );
var pixels : ByteArray = ( mBitmaps[atlasName] as Bitmap ).bitmapData.getPixels( textureRegion );
pixels.position = 0;
bitmapData.setPixels( new Rectangle( regionLeft, regionTop, regionWidth, regionHeight ), pixels );
return new Bitmap( bitmapData );
}