10 Replies Latest reply on Oct 6, 2006 4:19 PM by Dr._Goomba

    Send data to CFC via RemoteObject?

      I am able to receive data from my CFC via RemoteObject, but how can i send data to my CFC using RemoteObject?

        • 1. Re: Send data to CFC via RemoteObject?
          Dr._Goomba Level 1
          Nevermind, i figured it out. Much easier than i expected.

          • 2. Re: Send data to CFC via RemoteObject?
            GeorgeWS Level 1
            Dr. Goomba
            How did you do this? Can you post a sample please
            • 3. Re: Send data to CFC via RemoteObject?
              GeorgeWS Level 1
              Can you tell or show me how Im getting desperate?
              • 4. Re: Send data to CFC via RemoteObject?
                Dr. Goomba, can you share the solution with us?


                • 5. Re: Send data to CFC via RemoteObject?
                  Dr._Goomba Level 1
                  Heres the code, i will try to sum it up.

                  1. RemoteObject retrieves data from cfc, and sends data to CFC. RemoteObject DOES NOT populate with any new data but we will make it look like it is by appending a dvdItem to the dvds array.

                  2. dvdsReceived populates the dvds ArrayCollection, use this Array as your data provider.

                  3. When addItem() runs, it does the following:
                  a. it creates a new dvdItem (a new record in the dvds ArrayCollection)
                  b. it announces the addItem event
                  c. the event is caught by addEventListener("addItem",saveDVD)
                  d. which then runs saveDVD() who sends the data to the remote object via "save"
                  c. the remoteObject save method returns the received result to dvdSaved()
                  e. dvdSaved() appends the dvdItem to the dvds array.

                  your data provider will now show the newly entered item. hope this helps!

                  <!-- grabs data, and saves data to cfc -->
                  showBusyCursor="true" source="movies.mMoviesGateway"
                  fault="Alert.show(event.fault.faultString, 'Error');">
                  <mx:method name="getAll" result="dvdsReceived(event)" />
                  <mx:method name="save" result="dvdSaved(event)" />
                  import mx.collections.ArrayCollection;
                  import mx.controls.Alert;
                  import mx.rpc.events.*;
                  import mx.events.*;

                  // create variable to hold results
                  private var dvds:ArrayCollection = null;

                  // run on application complete
                  private function setUp():void {

                  // saves remoteobject results into dvds arraycollection
                  private function dvdsReceived(event:ResultEvent):void {
                  dvds = new ArrayCollection();
                  dvds.source = event.result as Array;

                  // sends saved item to remote object
                  private function saveDVD(event:ItemClickEvent):void{
                  var dvdItem:mMovies = event.item as mMovies;

                  // append saved dvd to dvds array (remote object wont push new data to remoteobject, so just add new data to dvds array)
                  private function dvdSaved(event:ResultEvent):void {
                  var dvdItem:mMovies = event.result as mMovies;
                  // run this when 'add' button clicked
                  private function addItem():void
                  var addItemEvent:ItemClickEvent = new ItemClickEvent("addItem", true);
                  //create a new dvd object
                  var dvdItem:mMovies = new mMovies();
                  //set its properties using the data entered in the form
                  dvdItem.title = title.text;
                  addItemEvent.item = dvdItem;

                  //announce this event

                  private function clearForm():void{
                  title.text = '';
                  • 6. Re: Send data to CFC via RemoteObject?
                    cheftimo Level 2
                    GeorgeWS and davidmedifit:

                    Being a newbie, I’ve been studying this Flex business and made a very simple app, a form that you fill out to filter data; it’s sent to the CFC, then a DataGrid displays the results; the data comes from a database. You can see it at

                    Here is the relevant code:

                    import mx.rpc.events.ResultEvent;
                    import mx.controls.Alert;
                    import mx.collections.ArrayCollection;

                    private var qResult:ArrayCollection;

                    private function clearAll():void{
                    qResult=new ArrayCollection();

                    private function handleQueryResult(event:ResultEvent):void
                    qResult=event.result as ArrayCollection;

                    fault="Alert.show(event.fault.message)" >
                    <mx:method name="ListContactsFound" result="handleQueryResult(event)" >

                    I got all this by studying Kyle Quevillon’s HelloWorld_ro sample app, which you will find at

                    I hope this helps. If you need to know more, I’ll be checking the forums again in a couple of days, as I am now traveling, and I’ll be glad to help in any way I can. Good luck,


                    • 7. Re: Send data to CFC via RemoteObject?
                      davidmedifit Level 1
                      Dr. Goomba & Carlos - much thanks.

                      • 8. Re: Send data to CFC via RemoteObject?
                        GeorgeWS Level 1
                        I do like your sample and I cant get it to work. I try your link and it does not work either.
                        • 10. Re: Send data to CFC via RemoteObject?
                          Dr._Goomba Level 1
                          Check out Flex 2 Training from the Source at http://safari.oreilly.com/0321496078. It will explain everything for you.