Event Propogation


<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml&#8221;
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>

Advertisements

~ by mjcprasad2000 on January 27, 2009.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: