loader.content question

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

loader.content question

jboadas
Hello

Im loading a png and loader.content is not working using

loader.contentLoaderInfo.addEventListener(Event.COMPLETE, function(_) { _bitmap = new Bitmap(cast( loader.content, Bitmap ).bitmapData); } ) ;

but if I use

_bitmapdata = new BitmapData(64, 64);
_bitmap = new Bitmap(_bitmapdata);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, function(_)
{ _bitmap.bitmapData.copyPixels(cast( loader.content, Bitmap ).bitmapData,
 new Rectangle(0,0,64,64),
 new Point()); } ) ;

It works fine.

I was thinking that it have something to do with the width and heigth of the png but Im not sure.

can anyone give me some light on this.

Best Regards

--
Jesus Boadas
[hidden email]

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: loader.content question

jlm@justinfront.net
when loading an image I normally create a rectangle transparent the same size above if I need a hit area, this seems to be run time limitation of flash, I would not copyPixels just use the drawing api for a transparent rectangle.

On 25 Oct 2011, at 16:02, Jesus Boadas wrote:

Hello

Im loading a png and loader.content is not working using

loader.contentLoaderInfo.addEventListener(Event.COMPLETE, function(_) { _bitmap = new Bitmap(cast( loader.content, Bitmap ).bitmapData); } ) ;

but if I use

_bitmapdata = new BitmapData(64, 64);
_bitmap = new Bitmap(_bitmapdata);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, function(_)
{ _bitmap.bitmapData.copyPixels(cast( loader.content, Bitmap ).bitmapData,
 new Rectangle(0,0,64,64),
 new Point()); } ) ;

It works fine.

I was thinking that it have something to do with the width and heigth of the png but Im not sure.

can anyone give me some light on this.

Best Regards

--
Jesus Boadas
[hidden email]
--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: loader.content question

Baluta Cristian
It's not working probably because it considers the bitmapdata of size 0x0
It seems strange to me to use cast, why wouldn't you go the normal way?

Baluta Cristian

On 25.10.2011, at 18:44, "[hidden email]" <[hidden email]> wrote:

when loading an image I normally create a rectangle transparent the same size above if I need a hit area, this seems to be run time limitation of flash, I would not copyPixels just use the drawing api for a transparent rectangle.

On 25 Oct 2011, at 16:02, Jesus Boadas wrote:

Hello

Im loading a png and loader.content is not working using

loader.contentLoaderInfo.addEventListener(Event.COMPLETE, function(_) { _bitmap = new Bitmap(cast( loader.content, Bitmap ).bitmapData); } ) ;

but if I use

_bitmapdata = new BitmapData(64, 64);
_bitmap = new Bitmap(_bitmapdata);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, function(_)
{ _bitmap.bitmapData.copyPixels(cast( loader.content, Bitmap ).bitmapData,
 new Rectangle(0,0,64,64),
 new Point()); } ) ;

It works fine.

I was thinking that it have something to do with the width and heigth of the png but Im not sure.

can anyone give me some light on this.

Best Regards

--
Jesus Boadas
[hidden email]
--
haXe - an open source web programming language
http://haxe.org

--
haXe - an open source web programming language
http://haxe.org

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: loader.content question

jboadas
Very thanks for your answers

Do you mean the normal way using swfmill?,
Im using this because Im coding for multiples targets and have some examples that work fine with this.

here http://gm2d.com/2009/02/simple-flash-game-in-haxe/

// Create the request object...
var loader = new flash.display.Loader();
// When the image is ready, instanciate the game class...
loader.contentLoaderInfo.addEventListener(flash.events.Event.COMPLETE,
function(_) { new Ski(untyped loader.content.bitmapData); });

is using untyped, it works in my main file but if I create a class to manage all may tiles doesnt work and give me this error

src/TileManager.hx:23: characters 96-121 : Cannot access this in 'untyped' mode : use either '__this__' or var 'me = this' (transitional)

Best regards

Jesus Boadas
[hidden email]

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: loader.content question

bubblebenj
Humm, if your using NME, don't forget to mention it.
Without that the only target that can achieve what your asking is flash.

Hope the new NME mailing list will disambiguate the difference between haXe and NME.

Ben

On Tue, Oct 25, 2011 at 10:05 PM, Jesus Boadas <[hidden email]> wrote:
Very thanks for your answers

Do you mean the normal way using swfmill?,
Im using this because Im coding for multiples targets and have some examples that work fine with this.

here http://gm2d.com/2009/02/simple-flash-game-in-haxe/

// Create the request object...
var loader = new flash.display.Loader();
// When the image is ready, instanciate the game class...
loader.contentLoaderInfo.addEventListener(flash.events.Event.COMPLETE,
function(_) { new Ski(untyped loader.content.bitmapData); });

is using untyped, it works in my main file but if I create a class to manage all may tiles doesnt work and give me this error

src/TileManager.hx:23: characters 96-121 : Cannot access this in 'untyped' mode : use either '__this__' or var 'me = this' (transitional)

Best regards

Jesus Boadas
[hidden email]

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: loader.content question

jboadas
Sorry I forgot, Im using NME, here are a sample flash develop project game taken from

http://gm2d.com/2009/02/simple-flash-game-in-haxe/

and running the same codebase for flash, neko, html5 and cpp,

http://www.mediafire.com/?69ohovqngt6mxxi

I just copy and paste the code in flashdevelop and It works with only a little change for neko on line 295

    #if neko
       mArena.fillRect(new Rectangle(0, 0, 640, 480), BitmapData.createColor(0xE0E0ff,0xFF));
    #else
       mArena.fillRect(new Rectangle(0,0,640,480), 0xFFE0E0ff);//ARGB
    #end

and here is using untyped, but It not work outside the main class

on line 416

loader.contentLoaderInfo.addEventListener(flash.events.Event.COMPLETE,
function(_) { new Ski(untyped loader.content.bitmapData); });

--
Jesus Boadas
[hidden email]

--
haXe - an open source web programming language
http://haxe.org