Flex 4.5 -- 이벤트 (이벤트)
1 MXML 성명 이벤트 이용
<?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"
minWidth="955" minHeight="600" creationComplete="applicationCreateHandler()">
<fx:Script>
<![CDATA[
protected function button1_clickHandler():void{
dispatchEvent(new Event("Clicked"));
}
protected function applicationCreateHandler():void{
this.addEventListener("Clicked",clickedHandler);
}
private function clickedHandler(e:Event):void{
trace("Event Is Listened");
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Metadata>
[Event(name="Clicked",type="flash.events.Event")]
</fx:Metadata>
<s:Button x="344" y="194" id="button1" label="Click" click="button1_clickHandler()"/>
</s:Application>
2 Action Script 로 이벤트 설명
package com.event
{
import flash.events.Event;
public class MyEvent extends Event
{
public static const MY_EVENT:String = "myEvent";
private var eventObject:int;
public function MyEvent(type:String, param:int, bubbles:Boolean=false, cancelable:Boolean=false)
{
super(type, bubbles, cancelable);
this.eventObject=param;
}
public function getEventObject():int{
return this.eventObject;
}
}
}
<?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"
minWidth="955" minHeight="600" creationComplete="applicationHandler()">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import com.event.MyEvent;
protected function buttonClickHandler():void{
var event:MyEvent = new MyEvent(MyEvent.MY_EVENT,2);
dispatchEvent(event);
}
protected function applicationHandler():void{
this.addEventListener(MyEvent.MY_EVENT,eventHandler);
}
private function eventHandler(e:MyEvent):void{
trace(" : "+e.getEventObject());
}
]]>
</fx:Script>
<s:Button x="284" y="300" label="Button" click="buttonClickHandler()"/>
</s:Application>
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.