Flashで画像データをEmbedする時の注意。
Embedする時に同じ画像データを別のクラスとして登録すると不具合が(Flash CS4で)発生するのを回避する方法。
[Embed(source = "test_1.png")]
public var img_1:Class;
[Embed(source = "test_1.png")]
public var img_2:Class;
[Embed(source = "test_1.png")]
public var img_3:Class;
上記のように画像を埋め込むとうまくインスタンス化できない。
(エラーが出るわけでもない。)
[Embed(source = "test_1.png", scaleGridTop='0', scaleGridLeft='0', scaleGridRight='1', scaleGridBottom='1')]
public var img_1:Class;
[Embed(source = "test_1.png", scaleGridTop='0', scaleGridLeft='0', scaleGridRight='1', scaleGridBottom='1')]
public var img_2:Class;
[Embed(source = "test_1.png", scaleGridTop='0', scaleGridLeft='0', scaleGridRight='1', scaleGridBottom='1')]
public var img_3:Class;
上記のようにスケール9の設定をするとうまくインスタンス化される。
画像データをBitmapAssetで埋め込んでいるのを、スケール9を設定することでSpriteAssetとして埋め込むことで
問題が回避できるようだ。