특별한딸기이야기
커스텀 이벤트 본문
MultiButton.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="218" height="114"
resize="onResize()" initialize="onResize()">
<mx:Metadata>
[Event(name="btn1Clicked", type="flash.events.Event")]
[Event(name="btn2Clicked", type="flash.events.Event")]
[Event(name="btn3Clicked", type="flash.events.Event")]
[Event(name="btn4Clicked", type="flash.events.Event")]
</mx:Metadata>
<mx:Script>
<![CDATA[
public function onResize() : void
{
var w : int = this.width / 2;
var h : int = this.height / 2;
btn1.width = btn2.width = btn3.width = btn4.width = w;
btn1.height = btn2.height = btn3.height = btn4.height = h;
btn1.move(0, 0);
btn2.move(w, 0);
btn3.move(0, h);
btn4.move(w, h);
}
]]>
</mx:Script>
<mx:Button x="19" y="10" id="btn1" click="dispatchEvent(new Event('btn1Clicked'))" />
<mx:Button x="96" y="10" id="btn2" click="dispatchEvent(new Event('btn2Clicked'))" />
<mx:Button x="10" y="63" id="btn3" click="dispatchEvent(new Event('btn3Clicked'))" />
<mx:Button x="96" y="63" id="btn4" click="dispatchEvent(new Event('btn4Clicked'))" />
</mx:Canvas>
Study.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
xmlns:nsl="*">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
]]>
</mx:Script>
<nsl:MultiButton id="mb" x="10" y="10" width="141" height="80"
btn1Clicked="mx.controls.Alert.show('1')"
btn2Clicked="mx.controls.Alert.show('2')"
btn3Clicked="mx.controls.Alert.show('3')"
btn4Clicked="mx.controls.Alert.show('4')" />
</mx:Application>
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="218" height="114"
resize="onResize()" initialize="onResize()">
<mx:Metadata>
[Event(name="btn1Clicked", type="flash.events.Event")]
[Event(name="btn2Clicked", type="flash.events.Event")]
[Event(name="btn3Clicked", type="flash.events.Event")]
[Event(name="btn4Clicked", type="flash.events.Event")]
</mx:Metadata>
<mx:Script>
<![CDATA[
public function onResize() : void
{
var w : int = this.width / 2;
var h : int = this.height / 2;
btn1.width = btn2.width = btn3.width = btn4.width = w;
btn1.height = btn2.height = btn3.height = btn4.height = h;
btn1.move(0, 0);
btn2.move(w, 0);
btn3.move(0, h);
btn4.move(w, h);
}
]]>
</mx:Script>
<mx:Button x="19" y="10" id="btn1" click="dispatchEvent(new Event('btn1Clicked'))" />
<mx:Button x="96" y="10" id="btn2" click="dispatchEvent(new Event('btn2Clicked'))" />
<mx:Button x="10" y="63" id="btn3" click="dispatchEvent(new Event('btn3Clicked'))" />
<mx:Button x="96" y="63" id="btn4" click="dispatchEvent(new Event('btn4Clicked'))" />
</mx:Canvas>
Study.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
xmlns:nsl="*">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
]]>
</mx:Script>
<nsl:MultiButton id="mb" x="10" y="10" width="141" height="80"
btn1Clicked="mx.controls.Alert.show('1')"
btn2Clicked="mx.controls.Alert.show('2')"
btn3Clicked="mx.controls.Alert.show('3')"
btn4Clicked="mx.controls.Alert.show('4')" />
</mx:Application>
'딸기 공부방 > flex' 카테고리의 다른 글
액션스크립트 컴포넌트 (0) | 2008.12.27 |
---|---|
커스텀 프로퍼티 (0) | 2008.12.27 |
컴포넌트를 이용한 비디오 플레이어 (0) | 2008.12.27 |
컴포넌트 만들기 (1) | 2008.12.27 |
http로 서버에 정보 전달하기 (0) | 2008.12.27 |