yarekGmail
asked on
flex mouse event
hello experts,
Here is a very simple Flex code.
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
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>
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
ASKER
yes thanks I know that !
but "It is important not to change the layout (no nesting canvas)."
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.
ASKER
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
Forget it I solved it by myself. Try to answer to the quetsion if you kno wthe answer next time.
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.