Hi,

You are getting blank because you are trying to retrieve the value of
_result right after you send the data using HTTP Service. You will never get
the result this way. Change your approach to:

- in register_customer_Result() method, dispatch an event.
- when you call register_customer() method from the main application, do
addEventListener and listen to the above event.
- When register_customer_Result() method will dispatch the event, the
callback function you associate with the addEventListener will be called.
- Now in this callback function, you can do Alert.show(mysc.getResult());

Regards,
Venkat
www.venkatv.com


On Thu, Jan 1, 2009 at 5:57 PM, caydauxanh <[email protected]> wrote:

>
> I'm writing my class:
> package database
> {
>        import mx.rpc.events.ResultEvent;
>        import mx.rpc.http.HTTPService;
>
>        public class db_request
>        {
>                private var _service:HTTPService;
>                private var _params:Object;
>                private var _result:String;
>                private var _xml_result:XML;
>
>                public function db_request()
>                {
>                        _service = new HTTPService;
>                        _service.url = "http://localhost/backend/";;
>                        _service.method = "POST";
>                        _service.resultFormat = "xml";
>                        _params = new Object;
>                }
>
>                public function getResult():String
>                {
>                        return _result;
>                }
>
>                private function
> register_customer_Result(event:ResultEvent):void
>                {
>                        var myXML:XML = new XML(event.result);
>                        _result = myXML.result;
>                        import mx.controls.Alert;
>                        Alert.show(_result); // This show what I need
>                }
>
>                public function register_customer
> (email:String,password:String,name:String,phone:String,address:String):void
>                {
>                        _params['function'] = "register_customer";
>                        _params['email'] = email;
>                        _params['password'] = password;
>                        _params['name'] = name;
>                        _params['phone'] = phone;
>                        _params['address'] = address;
>                        _service.addEventListener(ResultEvent.RESULT,
> register_customer_Result);
>                        _service.send(_params);
>                }
>
>        }
> }
>
> And my application's code to show _result variable
> private function DoClick():void
>        {
>                var mysc:db_request = new db_request();
>                mysc.register_customer
> ("[email protected]","thetruth","mrdeen","1231232130","address");
>                Alert.show(mysc.getResult());
>        }
>
> It shows empty :((, Totally, I think that at the
> register_customer_Result function, it can not set value for variable
> _result.
> Any body help me?
> Thank you very much !
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Flex 
India Community" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/flex_india?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to