Hi, Before I answer your query, I would recommend you to use HTTPService or XML to load xml files. It would save you from lot of coding for doing simple things :)
Ok coming to your query. There are two things: 1) You are showing alert just after calling load(..). Chances are that data has not yet loaded and that's why onLoad is not yet called and newXML has not got set. 2) What you are thinking, is known thing(scope issue). You can be sure of scoping by using mx.utils.Delegate class to create callback function for onLoad. See the modified code below: function search() { var newXML; var myXML = new XML(); myXML.ignoreWhite = true; myXML.load("http://myserver.com/test.xml"); myXML.onLoad = mx.utils.Delegate.create(this, processXML); alert("Application::search()-> " + newXML) } function processXML(success:Boolean) { if(success){ newXML = "new value"; }else{ } alert("Application::processXML()-> " + newXML); } I have done another change. I have placed newXML in processXML(..) function also, I guess, you mean to pop-up an alert when xml is loaded and parsed. -abdul ________________________________ From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Dogra, Daman Sent: Thursday, June 30, 2005 1:19 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Scoping issue in event handler ? Hi, I am trying to set an external variable within an onLoad() event handler and later trying to access it as below . The variable in question here is newXML . After setting it within the eventHandler, trying to access it outside the eventHandler thru the alert statement on the last line brings up an empty pop-up. My guess is that this is a scoping issue...however I do not seem to be able to set the variable newXML (and later retrieve its value) the way I am trying to. Would appreciate any help with this . function search(){ var newXML; var myXML = new XML(); myXML.ignoreWhite = true; myXML.load("http://myserver.com/test.xml"); myXML.onLoad = function(success:Boolean){ if(success){ newXML = "new value"; }else{ } } alert(newXML); } Thanks -Daman -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com ________________________________ YAHOO! GROUPS LINKS * Visit your group "flexcoders <http://groups.yahoo.com/group/flexcoders> " on the web. * To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> * Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service <http://docs.yahoo.com/info/terms/> . ________________________________ -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/flexcoders/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/