2

Some imports I used:

import flash.display.BitmapData;
import flash.geom.Matrix;
import flash.geom.Rectangle;
import flash.geom.ColorTransform;
import starling.display.Sprite;
import starling.display.MovieClip;

I have here a BitmapData:

var bm_data:BitmapData = new BitmapData(rec.width, rec.height, false, 0); //rec is a rectangle

I got the transformation Matrixes:

var sprite_1_M:Matrix = sprite_1.transformationMatrix; //these are objs that extends starling.display.Sprite
var sprite_2_M:Matrix = sprite_2.transformationMatrix;

And here is the problem:

bm_data.draw(sprite_1.movie_clip, sprite_1_M, new ColorTransform(1,1,1,1,255,-255,-255), BlendMode.ADD);
bm_data.draw(sprite_2.movie_clip, sprite_2_M, new ColorTransform(1,1,1,1,-255,255,-255), BlendMode.ADD);

Error:

Implicit coercion of a value of type MovieClip to an unrelated type IBitmapDrawable

Any hints what should I do? A think flash movie clips would work...

João Paulo
  • 6,300
  • 4
  • 51
  • 80

1 Answers1

3

You can't use Flash's BitmapData.draw() with Starling display objects like that - they are completely separate things and use very different technology for rendering.

You can however use the starling.display.Stage.drawToBitmapData() method, which draws the contents of the Starling Stage to a Flash BitmapData object.

You could also get away with using starling.display.Sprite.flatten() to achieve a similar result AND allow placement of the resulting graphic within the Starling display tree (the Flash display tree sits on top of Starling meaning you can't layer them between each other).

Marty
  • 39,033
  • 19
  • 93
  • 162