우선 http://mudchobo.tomeii.com/tt/211 이거랑
http://mudchobo.tomeii.com/tt/214 이거를 참조하셔서 새로운 blazeds.war를 만들어서 톰캣에 띄워야합니다.
New Project로 만들고, ProjectName을 AirBlazedsTest라고 합시다.
Desktop application을 선택하고 J2EE를 선택하고, 넥스트를 누릅니다 ^^
Server location은 위에 따라했다면 그대로 되어 있을꺼에요^^
Finish를 클릭해줍시다.
AIR에서는 좀 다르게 몇줄을 더 추가해야하는데요.
[code]
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute">
<mx:Script>
<![CDATA[
import mx.messaging.ChannelSet;
import mx.messaging.channels.AMFChannel;
import mx.rpc.events.ResultEvent;
import mx.rpc.events.FaultEvent;
import mx.rpc.remoting.RemoteObject;
import mx.controls.Alert;
private var startTime:Number;
private function resultHandler(event:ResultEvent):void{
dg.dataProvider = event.result;
}
private function faultHandler(event:FaultEvent):void{
mx.controls.Alert.show("실패 메세지 : " + event.fault.message);
}
private function retrieve():void {
var amfChannel:AMFChannel = new AMFChannel(
"my-amf", "http://localhost:8080/blazeds/messagebroker/amf");
var channelSet:ChannelSet = new ChannelSet();
channelSet.addChannel(amfChannel);
var srv:mx.rpc.remoting.RemoteObject = new RemoteObject();
srv.channelSet = channelSet;
srv.destination = "member";
startTime = new Date().time;
srv.getElements();
srv.addEventListener("result",resultHandler);
srv.addEventListener("fault",faultHandler);
}
private function logResult():void {
if (startTime > 0) {
log.text = "" + (new Date().time - startTime) + " milliseconds";
}
}
]]>
</mx:Script>
<mx:Panel title="AS를 이용한 RemoteObject예" width="100%" height="100%">
<mx:DataGrid id="dg" width="100%" height="100%"
updateComplete="logResult()"/>
<mx:ControlBar>
<mx:Button label="데이터 가져오기" click="retrieve()"/>
<mx:Label id="log"/>
</mx:ControlBar>
</mx:Panel>
</mx:WindowedApplication>
[/code]
AIR에서도 돼요-_-; 레몬펜그은부분만 추가를 해주시면 돼요 ^^