dispatchEvent で任意のプロパティを渡す DynamicEvent
♥3 |
Line 37 |
Modified 2010-07-28 19:00:56 |
MIT License
archived:2017-03-08 21:53:11
ActionScript3 source code
/**
* Copyright matsu ( http://wonderfl.net/user/matsu )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/iCwZ
*/
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
creationComplete="creationCompleteHandler(event)">
<fx:Declarations>
<!-- 非ビジュアルエレメント (サービス、値オブジェクトなど) をここに配置 -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.events.DynamicEvent;
import mx.events.FlexEvent;
protected function creationCompleteHandler(event:FlexEvent):void
{
testButton.addEventListener(MouseEvent.CLICK, testButtonClick);
addEventListener("ClickComplete", clickCompleteHandler);
}
private function testButtonClick(event:MouseEvent):void
{
var dynamicEvent:DynamicEvent = new DynamicEvent("ClickComplete");
dynamicEvent.test = "Test";
dispatchEvent(dynamicEvent);
}
private function clickCompleteHandler(dynamicEvent:DynamicEvent):void
{
testLabel.text = dynamicEvent.test;
}
]]>
</fx:Script>
<s:VGroup>
<s:Label text="DynamicEvent Test" fontSize="20"/>
<s:HGroup verticalAlign="middle">
<s:Button id="testButton" label="click"/>
<s:Label id="testLabel"/>
</s:HGroup>
</s:VGroup>
</s:Application>