Inline Events
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
backgroundColor="#FFFFFF">
<mx:Label id="myL">
</mx:Label>
<mx:Button id="myButton" label="click me" click="myL.text='Button Clicked'"/>
</mx:Application>
Events in a separate script file(.as)
Create New .as file under src flder & name as functions.as
// ActionScript file
private function clickHandler():void
{
myL.text="Button Clicked";
}
From Main application
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
backgroundColor="#FFFFFF">
<mx:Script source="functions.as">
</mx:Script>
<mx:Label id="myL"/>
<mx:Button id="myButton"
label="Click Me"
click="clickHandler()"/>
</mx:Application>
Passing a Event Object to a action script method
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
backgroundColor="#FFFFFF">
<mx:Script>
<![CDATA[
import flash.events.MouseEvent;
private function clickHandler(event:MouseEvent):void
{
myL.text="Button Clicked";
targetLabel.text = event.target.id;
typeLabel.text = event.type;
}
]]>
</mx:Script>
<mx:HBox>
<mx:Label text="This is the target"/>
<mx:Label id="targetLabel"/>
</mx:HBox>
<mx:HBox>
<mx:Label text="This is the type"/>
<mx:Label id="typeLabel"/>
</mx:HBox>
<mx:Label id="myL"/>
<mx:Button id="myButton"
label="Click Me"
click="clickHandler(event)"/>
</mx:Application>
Convert DATETIME TO TIMESPAN IN C#
13 years ago
No comments:
Post a Comment