<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init()">
<mx:Metadata>
[Event(name='MyCustomEvent', type='events.MyCustomEvent')]
</mx:Metadata>
<mx:Script>
<![CDATA[
import events.MyCustomEvent;
import mx.controls.Alert;
public var state:String;
[Bindable]
public var myLabel:String;
private function init():void {
addEventListener(events.MyCustomEvent.MY_CUSTOM_EVENT, function(event:MyCustomEvent):void {
Alert.show('hello from component: ' + event.state);
});
}
public function clickMe(e:MouseEvent):void {
var state:String = state;
var bubbleUp:Boolean = bubble.selected;
dispatchEvent(new MyCustomEvent(state, events.MyCustomEvent.MY_CUSTOM_EVENT, bubbleUp));
}
]]>
</mx:Script>
<mx:Button label="{myLabel}" click="clickMe(event)" />
<mx:CheckBox id="bubble" label="Bubble?" left="110" />
</mx:Canvas>