<?xml version="1.0"
encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" verticalAlign="top"
horizontalAlign="center"
backgroundGradientColors="[#570A0A, #731F1F]" paddingTop="0"
backgroundGradientAlphas="[1.0, 1.0]" xmlns:local="*">
<!-- Handling Events -
Inline Property -->
<mx:Panel x="10" y="10" width="250" height="200" layout="absolute" title="Inline Property" color="#F6FCFD">
<mx:Button label="click me"
click="mx.controls.Alert.show('clicked!')" x="79" y="59" color="#050606"/>
</mx:Panel>
<mx:Panel x="268" y="10" width="250" height="200" layout="absolute" title="Inline Block" color="#F7F9FA">
<mx:Button id="p2b" label="click me once" color="#0F1111" x="64" y="58">
<mx:click>
p2b.enabled = false;
mx.controls.Alert.show('clicked!');
</mx:click>
</mx:Button>
</mx:Panel>
<mx:Panel x="10" y="218" width="250" height="200" layout="absolute" title="Function" color="#FBFBFB">
<mx:Script>
private function handleClick(event:MouseEvent):void
{
p3b.enabled = false;
mx.controls.Alert.show('clicked!');
}
</mx:Script>
<mx:Button id="p3b" label="click me once"
click="handleClick(event)" x="64" y="59" color="#0F0E0E"/>
</mx:Panel>
<mx:Panel x="268" y="218" width="250" height="200" layout="absolute" title="addEventListener" color="#FBFEFF">
<!-- Handling Events -
Function with addEventListener -->
<mx:Script>
private function
eHandleClick(event:MouseEvent):void
{
b.enabled = false;
mx.controls.Alert.show('clicked!');
}
</mx:Script>
<mx:Button id="b" label="click me once" x="64" y="58" color="#121516">
<mx:creationComplete>
b.addEventListener(MouseEvent.CLICK, eHandleClick);
</mx:creationComplete>
</mx:Button>
</mx:Panel>
<mx:Panel x="526" y="10" width="250" height="200" layout="absolute" title="Five Seconds Event" color="#FBFDFE">
<mx:Script>
import mx.controls.Alert;
</mx:Script>
<mx:Label text="wait 5 seconds" color="#120F0F" x="72" y="46"/>
</mx:Panel>
<local:FiveSecondTrigger triggered="Alert.show('five second event triggered');"/>
<mx:Panel x="526" y="218" width="250" height="200" layout="absolute" color="#FAFBFB" title="Custom Event">
<mx:Button label="fire the event!"
click="dispatchEvent(new
MyEvent(MyEvent.TRIGGERED))" x="61" y="58" color="#101111"/>
</mx:Panel>
<mx:initialize>
addEventListener(MyEvent.TRIGGERED, function(event:MyEvent):void {
mx.controls.Alert.show('event handled!');
});
</mx:initialize>
</mx:Application>
No comments:
Post a Comment