Link to home
Start Free TrialLog in
Avatar of yarekGmail
yarekGmail

asked on

flex mouse event

hello experts,

Here is a very simple Flex code.
 
 
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">
<mx:Script>
	<![CDATA[
		import mx.controls.Alert;
		private function init():void {
			red.addEventListener(MouseEvent.CLICK , clicked);
			green.addEventListener(MouseEvent.CLICK , clicked);
			blue.addEventListener(MouseEvent.CLICK , clicked);
			
		}
		private function clicked(e:MouseEvent):void {
			Alert.show(e.currentTarget.name+" clicked");
		}
		
	]]>
</mx:Script>
		<mx:Canvas x="31" y="46" width="200" height="200" backgroundColor="#FF0000" id="red"  />
		<mx:Canvas x="31" y="46" width="200" height="200" backgroundColor="#00FF00"  id="green" />
		<mx:Canvas x="31" y="46" width="200" height="200" backgroundColor="#0000FF"  id="blue" />
	
</mx:Application>

Open in new window



What I try to achieve is to make red or green clickable.
It is important not to change the layout (no nesting canvas).
I can do it if I make blue visible = false, but I need to keep all layers visible !
It doesn't work if you remove the listener from blue neither.

So how to make the others layers answer the events ?

regards
Avatar of Plucka
Plucka
Flag of Australia image

The 3 canvas's are covering each other. So your only getting the click event to the top one

if you change the following lines like below


      <mx:Canvas x="11" y="46" width="200" height="200" backgroundColor="#FF0000" id="red"  />
      <mx:Canvas x="21" y="46" width="200" height="200" backgroundColor="#00FF00"  id="green" />
      <mx:Canvas x="31" y="46" width="200" height="200" backgroundColor="#0000FF"  id="blue" />


You can see them all and will be able to click them all.
Avatar of yarekGmail
yarekGmail

ASKER

yes thanks I know that !
but "It is important not to change the layout (no nesting canvas)."
Well what are you trying to achieve. Why would you want someone to click something that they cant see.
To simulate  a layer system like Photoshop.

Forget it I solved it by myself. Try to answer to the quetsion if you kno wthe answer next time.
Thanks
ASKER CERTIFIED SOLUTION
Avatar of mausamviki4all
mausamviki4all

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial