flash9 mouseevent on imported image

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

flash9 mouseevent on imported image

fallen-2

Hi List!

After using haxe for a while, i've just started to target flash9/as3 but ran into a (simple?) problem right away:

When attaching a jpg from a swf (created with swfmill) i'm not able to receive mouse events on that image.

The sample code:
/* -----------------
var s:MovieClip = flash.Lib.attach("image");

// draw something
s.graphics.moveTo( 0, 0 );
s.graphics.beginFill( 0x990000, 100 );
s.graphics.lineTo( 100, 0 );
s.graphics.lineTo( 100, 100 );
s.graphics.endFill();

s.mouseEnabled = true;
s.useHandCursor = true;
s.buttonMode = true;

s.addEventListener( MouseEvent.MOUSE_DOWN,  function(e:MouseEvent)
  {
   trace( "klick" );
  }
);
----------------- */

The event only fires when the mouse is over the drawn parts, not on the image.

Some hints would be very welcome!

Greetings,
fa

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

Re: flash9 mouseevent on imported image

Robin Palotai
I'm not sure that this has anything to do with your problem, but the
proper way of including images from swf library for flash9 is not the
Lib.attach() way, but by defining a class like (that's what I read,
maybe Lib.attach still works):

class MyImg extends flash.display.Bitmap { public function new() { super(); } }

where MyImg is the "id" attribute supplied in the swfmill xml (itt
must start uppercase).

Try it, maybe this fixes it.

Cheers!
Robin

On Fri, Oct 31, 2008 at 12:04 PM, Fallen <[hidden email]> wrote:

>
> Hi List!
>
> After using haxe for a while, i've just started to target flash9/as3 but ran into a (simple?) problem right away:
>
> When attaching a jpg from a swf (created with swfmill) i'm not able to receive mouse events on that image.
>
> The sample code:
> /* -----------------
> var s:MovieClip = flash.Lib.attach("image");
>
> // draw something
> s.graphics.moveTo( 0, 0 );
> s.graphics.beginFill( 0x990000, 100 );
> s.graphics.lineTo( 100, 0 );
> s.graphics.lineTo( 100, 100 );
> s.graphics.endFill();
>
> s.mouseEnabled = true;
> s.useHandCursor = true;
> s.buttonMode = true;
>
> s.addEventListener( MouseEvent.MOUSE_DOWN,  function(e:MouseEvent)
>  {
>   trace( "klick" );
>  }
> );
> ----------------- */
>
> The event only fires when the mouse is over the drawn parts, not on the image.
>
> Some hints would be very welcome!
>
> Greetings,
> fa
>
> --
> 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: flash9 mouseevent on imported image

fallen-2
Hi Robin,
thx for the answer! Yeah, that did the trick. But it seems to fail (nothng is rendered, methods not called) if the linkage id is a clip with multiple images

/* -------------
<clip id="ImAnim1" import="library/image01.jpg"/>
<clip id="ImAnim2" import="library/image02.jpg"/>

<clip id="Animation" class="Animation">
        <frame><place id="ImAnim1" depth="1"/></frame>
        <frame><place id="ImAnim1" depth="1"/></frame>
</clip>
------------- */

This might be a problem of swfmill (0.2.12.4) as Daniel Fischer hinted at in this post:
http://haxe.markmail.org/message/2qzzv3eb5v7mmum6?q=load+image+swfmill

0.2.12.5 is not available in binary form for windows though...


BUT the Lib.attach() way still works (even for multiple images). To fire the event i have to overlay the image with another MovieClip which has a rect of the image size (alpha=0) draw to it.

Not nice, but it works.

Greetings,
Fallen


> I'm not sure that this has anything to do with your problem, but the
> proper way of including images from swf library for flash9 is not the
> Lib.attach() way, but by defining a class like (that's what I read,
> maybe Lib.attach still works):
>
> class MyImg extends flash.display.Bitmap { public function new() { super(); } }
>
> where MyImg is the "id" attribute supplied in the swfmill xml (itt
> must start uppercase).
>
> Try it, maybe this fixes it.
>
> Cheers!
> Robin
>
> On Fri, Oct 31, 2008 at 12:04 PM, Fallen <[hidden email]> wrote:
>>
>> Hi List!
>>
>> After using haxe for a while, i've just started to target flash9/as3 but ran into a (simple?) problem right away:
>>
>> When attaching a jpg from a swf (created with swfmill) i'm not able to receive mouse events on that image.
>>
>> The sample code:
>> /* -----------------
>> var s:MovieClip = flash.Lib.attach("image");
>>
>> // draw something
>> s.graphics.moveTo( 0, 0 );
>> s.graphics.beginFill( 0x990000, 100 );
>> s.graphics.lineTo( 100, 0 );
>> s.graphics.lineTo( 100, 100 );
>> s.graphics.endFill();
>>
>> s.mouseEnabled = true;
>> s.useHandCursor = true;
>> s.buttonMode = true;
>>
>> s.addEventListener( MouseEvent.MOUSE_DOWN,  function(e:MouseEvent)
>>  {
>>   trace( "klick" );
>>  }
>> );
>> ----------------- */
>>
>> The event only fires when the mouse is over the drawn parts, not on the image.
>>
>> Some hints would be very welcome!
>>
>> Greetings,
>> fa
>>
>> --
>> haXe - an open source web programming language
>> http://haxe.org
>>
>



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