Question

I'm trying to see how Starling could benefit the applications I build using as3. My knowledge thus far of Starling is that it only uses bitmap objects not symbol objects. How do I take a BitmapData class and create an starling Image out of it.

This bitmap was a symbol in flash that was converted into bitmap. It then had its properties modified to export for as3

Say there is a Ship BitmapData class in a swc. According to Starlings documentation of how it handles other bitmap like a png, I would think I should be able to do this.

 var myShip:Image = Image.fromBitmap(new Ship());

This of course doesn't work.

Was it helpful?

Solution

fromBitmap() expects to receive a bitmap object but here you are passing in a BitmapData Class. And Image class requires a texture.

Also your syntax is slightly incorrect.

NB. There is Texture.fromBitmap and Texture.fromBitmapData.

Although I haven't tried accessing assets from a swc you could try:

var myShip:Image = new Image(Texture.fromBitmapData(new Ship());

Perhaps try to get the Image appearing first before attempting to access the swc bitmapData

var bd:BitmapData = new BitmapData(100, 100, false, 0xFF0000);
var myShip:Image = new Image(Texture.fromBitmapData(bd);
addChild(myShip); //should display a red square
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top