box-o-sand/flex-practice/03b1-event-listeners/VBoxDemo.mxml

63 lines
1.5 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
name="DemoApplication"
backgroundColor="#FFFFFF"
backgroundAlpha="0"
creationComplete="initApp()"
>
<mx:Script>
<![CDATA[
import flash.events.EventPhase
import mx.controls.Alert;
private function initApp():void {
myVBox2.addEventListener("click", myHandleClick);
myVBox3.addEventListener("click", myHandleClick2);
}
private function myHandleClick(event:Event):void {
label1.text = "You clicked VBox 2";
}
private function myHandleClick2(event:Event):void {
myVBox2.removeEventListener("click",myHandleClick);
label1.text = "";
}
]]>
</mx:Script>
<mx:Label text="Application"/>
<mx:VBox id="myVBox1"
backgroundColor="#FFCCFF"
width="300" height="100"
horizontalAlign="center">
<mx:Label text="VBox 1" />
</mx:VBox>
<mx:VBox id="myVBox2"
backgroundColor="#FFCCCC"
width="300" height="100"
horizontalAlign="center">
<mx:Label text="VBox 2" />
</mx:VBox>
<mx:VBox id="myVBox3"
backgroundColor="#FFFFCC"
width="300" height="100"
horizontalAlign="center">
<mx:Label text="VBox 3" />
</mx:VBox>
<mx:Label id="label1"
width="80%" height="48"
fontWeight="bold" />
</mx:Application>