adding event propagation demo
This commit is contained in:
parent
519d3c5bea
commit
708fe18385
57
03b-event-propagation/DemoApplication.mxml
Normal file
57
03b-event-propagation/DemoApplication.mxml
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
<?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>
|
Loading…
Reference in New Issue
Block a user