58 lines
1.6 KiB
XML
58 lines
1.6 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()"
|
|
click="myHandleClick(event)"
|
|
>
|
|
|
|
<mx:Script>
|
|
<![CDATA[
|
|
import flash.events.EventPhase
|
|
import mx.controls.Alert;
|
|
|
|
private function initApp():void {
|
|
myVBox.addEventListener("click", myHandleClick);
|
|
}
|
|
|
|
private function myHandleClick(event:Event):void {
|
|
label1.text = "You clicked on " + event.target +
|
|
"\n" + "Current event phase is " +
|
|
getPhaseName(event.eventPhase) + "\n" +
|
|
"Current target is " + event.currentTarget
|
|
}
|
|
|
|
private function getPhaseName(phase:uint):String {
|
|
switch(phase) {
|
|
case 1:
|
|
return "CAPTURING PHASE";
|
|
case 2:
|
|
return "AT TARGET PHASE";
|
|
case 3:
|
|
return "BUBBLING PHASE";
|
|
}
|
|
return "";
|
|
}
|
|
]]>
|
|
</mx:Script>
|
|
<mx:Label text="Application"/>
|
|
|
|
<mx:VBox id="myVBox"
|
|
backgroundColor="#FFCCCC"
|
|
width="300" height="100"
|
|
horizontalAlign="center">
|
|
|
|
<mx:Label text="VBox"/>
|
|
|
|
<mx:Button id="myButton"
|
|
label="Create Click Event"
|
|
click="myHandleClick(event)" />
|
|
|
|
</mx:VBox>
|
|
<mx:Label id="label1"
|
|
width="80%" height="48"
|
|
fontWeight="bold" />
|
|
|
|
</mx:Application>
|