| micromacro |
27.09.2009 20:49 |
В чём разница моего кода с RemObj и NetCon?
Здравствуйте дорогие товарищи!
У меня такая проблема, разбираясь с примерами застрял на Net Connection, если я юзаю флекс с ремут обжект то всё нормально работает. Если юзаю Net connection и чистый акшиный хрипт то ничего не работает :boredom: Подскажите пжлста где я накасячил?
Вот это работает:
Код AS1/AS2:
<?xml version="1.0"?>
<!-- intro\intro_remoting.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
width="100%" height="100%">
<mx:Script>
<![CDATA[
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import flash.system.Security;
// Send the message in response to a Button click.
private function echo():void {
var text:String = ti.text;
remoteObject.echo(text);
}
// Handle the recevied message.
private function resultHandler(event:ResultEvent):void {
ta.text += "Server responded: "+ event.result + "\n";
}
// Handle a message fault.
private function faultHandler(event:FaultEvent):void {
ta.text += "Received fault: " + event.fault + "\n";
}
]]>
</mx:Script>
<mx:RemoteObject id="remoteObject"
destination="echoServiceDestination"
result="resultHandler(event);"
fault="faultHandler(event);">
</mx:RemoteObject>
<mx:Label text="Enter a text for the server to echo"/>
<mx:TextInput id="ti" text="Hello World!"/>
<mx:Button label="Send" click="echo();"/>
<mx:TextArea id="ta" width="100%" height="100%"/>
</mx:Application>
А вот эта собака не показывает данных вообще:
Код AS1/AS2:
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%"
creationComplete="creationCompleteHandler();">
<!--
-->
<mx:Panel id="mainPanel" height="100%" width="100%">
<mx:HBox>
<mx:Label text="Wellcome to hell please press button to echo"/>
<mx:TextInput id="ti" text="Hello World!"/>
<mx:Button label="Send" click="echo()"/>
<mx:Button label="Clear" click='ta.text = ""'/>
</mx:HBox>
<mx:TextArea id="ta" width="100%" height="100%"/>
</mx:Panel>
<mx:Script>
<![CDATA[
import flash.net.NetConnection;
import flash.net.ObjectEncoding;
import flash.net.Responder;
private var nc:NetConnection
private function creationCompleteHandler():void
{
nc = new NetConnection();
nc.objectEncoding = ObjectEncoding.AMF0;
nc.connect("http://localhost:7001/blazeds_unziped/messagebroker/amf" );
}
private function echo():void
{
nc.call( "EchoService.echo", new Responder( resultHandler, faultHandler ), ti.text );
}
private function resultHandler(result:Object):void
{
ta.text += "Server responded: "+ result + "\n";
}
private function faultHandler(fault:Object):void
{
ta.text += "Received fault: " + fault + "\n";
}
]]>
</mx:Script>
</mx:Application>
|