Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Returning results from remoteobject class to parent

Posted on 2014-11-12
1
Medium Priority
?
308 Views
Last Modified: 2015-05-12
I have a Flex application using ColdFusion to retrieve data from MS SQL. I'm trying to create a class where I can send in a numeric argument and it returns a value to the document calling the class.

This is my class

package com.procost
{
import mx.controls.Alert;
    import mx.core.FlexGlobals;
    import mx.rpc.AbstractOperation;
    import mx.rpc.events.ResultEvent;
    import mx.rpc.remoting.RemoteObject;

    public class EmailListRetrieve
    {
        public var emailListId:Number = -1;

        public function send():void{
            //Create the remote object
            var _remoteObject:RemoteObject = new RemoteObject('test');
            _remoteObject = new RemoteObject("ColdFusion");
            _remoteObject.endpoint = "http://" + FlexGlobals.topLevelApplication.endPointLink + "/flex2gateway/";
            _remoteObject.source = FlexGlobals.topLevelApplication.remotePath + "services.general";
            _remoteObject.showBusyCursor = true;

            //Send
            var op:AbstractOperation = _remoteObject.getOperation('getEmailList');
            op.addEventListener(ResultEvent.RESULT, result);
            op.send(this);
        }

        // Result from CFC
        private function result(event:ResultEvent){
            Alert.show(event.result.toString());
        }
    }
}

Open in new window


This is how I'm calling it from my MXML file

import com.procost.EmailListRetrieve;    

public function fncClick():void{
     var request:EmailListRetrieve = new EmailListRetrieve();
     request.emailListId=1;
     request.send();
}

Open in new window


The result function in my class is returning all the data I need from the DB. The issue is, how do I get this data back into the MXML document I called it from?

Any help would be appreciated.
0
Comment
Question by:RenAndStimpy
1 Comment
 
LVL 29

Accepted Solution

by:
Pravin Asar earned 2000 total points
ID: 40439130
After your get result in, assuming you have public variable defined to hold the returned value, got can add
get method

For example:

      public var returnedValue:String;

       // Result from CFC
        private function result(event:ResultEvent){
            Alert.show(event.result.toString());
            setReturnedValue(event.result as String);
        }

       public function setReturnedValue(str:String):void {
             returnedValue = new String (str);
       }
       public function getReturnedValue():String {
             return returnedValue;
       }
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Measuring Server's processing rate with a simple powershell command. The differences in processing rate also was recorded in different use-cases, when a server in free and busy states.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Suggested Courses

927 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question