I believe it is reccommended that lastResult only be used in binding expressions, though it appears to work as you show it.
Tracy ________________________________ From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of coderjun Sent: Wednesday, December 20, 2006 5:25 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: TypeError: Error #1009 - httpservice Titipouns, The reason you are getting the null reference error is because you are trying to assign the result of the HttpService call before the call has completed. (Remember, in Flex you have to remember things can work asynchronously.) In other words, rather than calling the affichebonjour() directly from the button click and running the userRequest.send() in there, instead, issue the userRequest.send() in the button click and call affichebonjour() as the result event handler for the HttpService. Here is your mxml file redone in a working state to reflect the above. -Jun <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml <http://www.adobe.com/2006/mxml> " layout="absolute"> <mx:Script> <![CDATA[ public function affichebonjour():void { affiche.text = userRequest.lastResult.message.affiche.info; } ]]> </mx:Script> <mx:HTTPService id="userRequest" url="donnees.xml" result="affichebonjour()"/> <mx:Button id="id_button" x="192" y="113" label="affiche bonjour" click="userRequest.send();"/> <mx:TextInput id="affiche" x="167" y="174"/> </mx:Application> --- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> , "titipouns19" <[EMAIL PROTECTED]> wrote: > > Hello, > > I try to display the word 'bonjour' (xml file) and when i click to > the button "id_button" i have this error : > > TypeError: Error #1009: Il est impossible d'accéder à la propriété ou > à la méthode d'une référence d'objet nul. > at affiche_bonjour/affichebonjour() > at affiche_bonjour/__id_button_click() > > - Here my xml file (donnees.xml) : > <message><affiche><info>bonjour</info></affiche></message> > > - Here my mxml page : > <?xml version="1.0" encoding="utf-8"?> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml > <http://www.adobe.com/2006/mxml> " > layout="absolute"> > > <mx:Script> > <![CDATA[ > > public function affichebonjour():void > { > userRequest.send(); > affiche.text = > userRequest.lastResult.message.affiche.info; > } > > ]]> > </mx:Script> > > > <mx:HTTPService id="userRequest" url="donnees.xml"/> > > <mx:Button id="id_button" x="192" y="113" label="affiche > bonjour" click="affichebonjour();"/> > > <mx:TextInput id="affiche" x="167" y="174"/> > > </mx:Application> > > Thanks for your help. > > Titipouns. >