Omar Alejandro
Omar Alejandro

Reputation: 47

The empty space of a canvas does not fire events in Flex

The empty space of a canvas does not fire events.

My problem is I have a canvas in an application that shows a diagram consisting of different figures, but the canvas empty places do not trigger the events that I need, as the rollover.

Can you tell me how I can make my canvas trigger events even in the empty spaces?.

I have set the background Color, mouseEnabled, color, border, alpha, opaqueBackground, etc, and nothing works.

I'm using Flex 4, and I have to use only a mx:Canvas.

Here is the event listener registration:

canDiagram.addEventListener(MouseEvent.ROLL_OVER, function(event:MouseEvent):void{if(actualCursor != null){CursorManager.setCursor(actualCursor,2,-10,-10);}},true);
canDiagram.addEventListener(MouseEvent.ROLL_OUT, function(event:MouseEvent):void{CursorManager.removeAllCursors();},true);

Upvotes: 1

Views: 258

Answers (2)

chrsmrtn
chrsmrtn

Reputation: 121

You'll need to make sure to set a color to the backgroundColor along with setting backgroundAlpha to 0. This makes sure it's still transparent, and your mouse events will fire. Here's my test canvas that i used to get it working

<mx:Canvas x="104" y="107" width="215" height="134" backgroundAlpha="0" 
           backgroundColor="#FFFFFF" rollOut="canvas1_rollOutHandler(event)"
           rollOver="canvas1_rollOverHandler(event)">
</mx:Canvas>

Upvotes: 1

Wesley Petrowski
Wesley Petrowski

Reputation: 1131

Normally, this type of problem can be fixed by setting a backgroundColor and setting the backgroundAlpha to 0.

You say you've already tried that; can you post an example of your Canvas definition?

I would also put a trace statement or something similar in your event handlers, just to make sure that they aren't actually being called. I've had situations where I couldn't figure out why a particular event wasn't firing, only to find that it was, but my handler just wasn't doing what I expected.

Upvotes: 0

Related Questions