Hello,
I am a newbie and I am trying a simple application to test
RPC using RemoteObject. My application takes a name from a text
input field and prints the welcome greeting in a text area.
The method to execute in my RemoteObject is a goofy method
that takes a person's name and returns the String welcoming the
person.
Here is the method.
package rpc.playerinfo;
public class PlayerService {
public String printThis(String name) {
return "Welcome to " + name;
}
}
I've added a destination representing this remote object in
the remote-config.xml file.
<destination id="PlayerDB">
<properties>
<source>rpc.playerinfo.PlayerService</source>
</properties>
</destination>
My MXML code is given below :
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"layout="absolute">
<mx:Script>
<![CDATA[
import rpc.playerinfo.*;
private function fillTxt(b: String):void{
mainTxt.text = b;
}
]]>
</mx:Script>
<mx:RemoteObject id="play" destination="PlayerDB">
<mx:method name="printThis" concurrency="last"
result="fillTxt(event.result as String)"/>
</mx:RemoteObject>
<mx:Panel title="Get Player">
<mx:TextArea id = "mainTxt"/> <!-- This is where
the output goes-->
<mx:TextInput id="txtNumber"/> <!-- This is where
the text is input-->
<mx:Button label="i like to print"
click="play.printThis(txtNumber.text)" /> <--Call the remote
object here -->
</mx:Panel>
</mx:Application>
When I try to run it, I get the following error, when I click
the button.
[RPC Fault faultString="[MessagingError message='Unknown
destination 'PlayerDB'.']" faultCode="InvokeFailed"
faultDetail="Couldn't establish a connection to 'PlayerDB'"]
at mx.rpc::AbstractInvoker/
http://www.adobe.com/2006/flex/mx/internal::invoke() at mx.rpc.remoting.mxml::Operation/
http://www.adobe.com/2006/flex/mx/internal::invoke() at mx.rpc.remoting::Operation/send()
at Function/
http://adobe.com/AS3/2006/builtin::apply() at mx.rpc.remoting.mxml::Operation/send()
at Function/
http://adobe.com/AS3/2006/builtin::apply() at mx.rpc::AbstractService/
http://www.adobe.com/2006/actionscript/flash/proxy::callProperty() at RPCDataService/___Button1_click()
Please help this newbie. Thank you.