views:

82

answers:

3

Hello,

My goal is to make a wide map using only one square image. Using actionscript 3 the solution is to simply make new Bitmap from the Loader:

var loader:Loader = new Loader();
loader.load(new URLRequest("xyz.png")); 
this.addChild(loader);  

var duplicationBitmap:Bitmap = new Bitmap(Bitmap(loader.content).bitmapData);

Unluckily, Haxe API doesn't allow to do that. I can't get bitmapData from loader content…

Anyone has a clue? Thanks.

+1  A: 

What you mean the API doesn't allow it? By looking at these:

http://haxe.org/api/flash9/display/loader http://haxe.org/api/flash9/display/bitmap

It seems you should be able to port that code?

Are you getting any compiler error?

J

Zárate
posted at the same time, I agree : )
Theo.T
I get an "flash.display.#Bitmap cannot be called" error. I mean that the loader.content is a DisplayObject which hasn't any bitmapData attribute…
Johnny Oin
Sorry I can't rate you up, i'm too low rep…
Johnny Oin
A: 

That's really weird, Bitmap is coming from the playerglobal.swc and shouldn't be related to any haXe specific "API". Aren't you just attempting to access loader.content whilst the content is not yet loaded (i.e. the example above).

Theo.T
I tried to use a listener which makes the duplicationBitmap only after finishing loading the image, but I got the same error: "flash.display.#Bitmap cannot be called"
Johnny Oin
Sorry I can't rate you up, i'm too low rep…
Johnny Oin
+2  A: 

The API is the very same, so I guess the problem is how you are trying to cast; try using:

var duplicationBitmap= new Bitmap(cast(loader.content, Bitmap).bitmapData);
Franco Ponticelli
Yes that works very well. Thanks!
Johnny Oin
Sorry I can't rate you up, i'm too low rep…
Johnny Oin
No problem, I am glad I can help.
Franco Ponticelli