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

How to Backup Your Blogger/Blogspot Blog

There has been a lot of times when my entries here magically disappeared costing me several months of work. Fortunately, there is now an easy way to backup Blogspot blogs. In your blog's control panel, if you look under the Settings tab, you will see Blog Tools section. Beside it you will see an option to Import Blog, Export Blog, and Delete Blog. Export Blog will allow you to save the contents of your blog in your hard disk. Import Blog will allow you to restore a previously saved copy. Related Link: To Begin Again

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.

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