Question

I'm trying to convert an old project of mine to use Starling for some extra performance. I've come to a problem when I'm loading my SWFs and trying to display them.

Here is the code I used before: (no Starling)

private function swfLoaded(e:LoaderEvent):void {
    var spr:Sprite = new Sprite();
    spr = e.currentTarget.content;
    bitmapData.draw(spr ...);
}

The problem when I'm using Starling is that the currentTarget.content is a flash.display.displayObject.

cannot convert com.greensock.loading.display::ContentDisplay@90ffec1 to starling.display.Sprite

I want to find a way to "convert" the flash.display.displayObject into a starling Sprite. I also want to be able to store the loaded swfs content into a array as a sprite.

Thanks in advance, Tompa

Was it helpful?

Solution

You're overwriting spr with a different value immediately after you create it, for one thing.

After you do the bitmapData.draw() call:

var tex:Texture = Texture.fromBitmapData(bitmapData, false, false);

The new texture can then be used to create a Starling Image sprite.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top