Skip to main content

Adobe Flex: Specifying Remote Object End Point

Update September 2009:  (In Adobe Flex SDK 3.3 and older, there is a difference between mx.rpc.remoting.RemoteObject and mx.rpc.remoting.mxml.RemoteObject.  The first one does not have an endpoint parameter that is why you can't dynamically specify the endpoint using Actionscript.

That is why I use mx.rpc.remoting.mxml.RemoteObject.

But as of Adobe Flex SDK 3.4, you can now use endpoint parameter with mx.rpc.remoting.RemoteObject. )


This is the sample code I use to call a Remote Object in Actionscript rather than the usual Adobe Flex MXML tag.

There are some advantages to doing your code this way. Like you can specify the endpoint dynamically.

You will need this import statements.


import mx.events.CloseEvent;
import mx.collections.ArrayCollection;
import mx.utils.ArrayUtil;
import mx.rpc.events.ResultEvent;
import mx.rpc.events.FaultEvent;
import mx.rpc.remoting.mxml.RemoteObject;

var clientrecs:ArrayCollection;
...


I use a one fault handler for all remote object calls in case a problem occurs.

private function faultHandler (event:FaultEvent):void {

      Alert.show(event.fault.faultString, 'Error');
} // faultHandler

This is a sample list function. In this case I am using AMFPHP. And of course my server side business objects are written in PHP.

private function listClients():void {

      var clientRO:RemoteObject = new RemoteObject();
     clientRO.endpoint = "amfphp/gateway.php";
     clientRO.source = "ClientObj" // PHP Object Name
    clientRO.destination = "amfphp";
    clientRO.listClients.addEventListener("result", listResult); // resutl handler
    clientRO.addEventListener("fault", faultHandler); // fault handler
    clientRO.listClients(cmbClientType.text); // call the service

}

A thing to remember. Your Remote Object source must be exactly the same as you have written in the Actionscript code. In this case its ClientObj. Remember this is case sensitive.

// Result Handlers
private function listResult(event:ResultEvent):void {

     clientrecs = new ArrayCollection(ArrayUtil.toArray(event.result));


}

Finally I pass the result to an Array Collection variable which I then bind to a DataGrid.

Goodluck.

Comments

Popular posts from this blog

LED Monitor Review: LG FLATRON E2041

My Old AOC CRT Monitor began to show signs of dying. It would occasionally black out for a few seconds. Sometimes lightning streaks  would run across the screen. I bought that monitor way back in 2006. It served me well for 5 years. It was very durable and AOC is a good brand. And so I had no choice but to buy myself a new monitor. I would have preferred another CRT Monitor but they were no longer available. Even the more recent LCD screens are being phased out in favor a the newer LED monitors. LG FLATRON E2041 (This was not my first choice but it was the next best thing available in the computer store I visited). 1600 X 900 Resolution (16:9 Aspect Ratio) Contrast Ratio: 5,000,000:1 Brightness: 250 Cd/m2 Dimensions W/Stand (WHD): 17.44" X 13.78" X 6.54" My Feedback This monitor comes with two connectors VGA and DVI. It comes with a CD that is supposed to contain the manual and monitor drivers. However, when you install the monitor driver contain...

GIMP: How to Enable Wacom Pen Tablet

If you are doing digital graphics in Gimp, whether painting or simply drawing, it is best to use a pen tablet. Wacom is a recognized brand when it comes to pen tablets. Gimp does support it but it is not enabled by default. How to Enable Pen Tablet Support 1. Launch Gimp using your pen tablet. Don't use the mouse to launch Gimp. If you do, Gimp won't detect it. 2. In the menu click Edit>Preference. 3. On the list click "Input Devices". 4. Click "Configure Extended Input Decives". Here is where Gimp gets weird. If you started Gimp for the first time using a mouse, it will say there are no available input device. But if you launched it using the pen tablet, you will see "Wacom Tablet Pressure Stylus" and "Wacom Tablet Eraser" . 5. Click the Close Button 6. Click "Save Input Device Settings Now" so that the pen tablet will still be supported when you launch Gimp next time.

How to remove popup.adv.net and mtn5.goole.ws - Final Solution

I usually have no problem dealing with trojans and malwares but this one proved to be the hardest one yet. Because it operates in ways we don't expect. Usually trojans operate within your PC but what if the exploit is hosted somewhere else on the web. Woah! This took a week. Thanks to the people who commented on this blog. I could not figure out this solution without all of you who bounced your ideas here.   Anyway, lets get rid of it . 1. In the Windows menu go to Start>Run 2. Type cmd 3. This will fire up the command window 4. Type ipconfig /all 5. This will display the actual configuration of your LAN card. Pay particular attention to the DNS entry. In my PC I got three entries: 0.255.122.15 85.255.112.156 1.2.3.4 Two of these entries are not correctly formed while 85.255.112.156 is the DNS address of the exploiter. A proper DNS entry given by your ISP should look something like - 58.69.254.143 6. Type ipconfig /release 7. Then ty...