I don't have time to set this up and try it, but a quick glance makes me guess that when you trace UserData.userInfo you get an empty collection instead of the data in data.xml.
That would be because the data hasn't been retrieved from the source yet. HTTPService is not blocking or synchronous so you have to send requests and wait for events indicating that the response is arrived and can't just start processing on the next line after the send. -Alexate so you know...d of April. bly needs to gettDocument.parentDocument, or even Application.application. o to get back to their ________________________________ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of xmrcivicboix Sent: Wednesday, February 07, 2007 10:31 PM To: [email protected] Subject: [flexcomponents] Scoping Issue Hi folks I have a scoping user that I'm struggling to understand. I can't seem to access UserData.userInfo at the application level because my variable is not scoped correctly. HELP ME! Anyways, here is my code: ---------------------------------------------------------- <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()"> <mx:Script> <![CDATA[ import com.UserDataRequest; import com.UserData; private var request:UserDataRequest; private function init(): void { request = new UserDataRequest("data.xml"); trace(UserData.userInfo); } ]]> </mx:Script> </mx:Application> UserDataRequest.as ---------------------------------------------------------- package com { import mx.rpc.http.HTTPService; import mx.rpc.events.ResultEvent; import com.UserData; import mx.collections.ArrayCollection; import mx.rpc.events.FaultEvent; public class UserDataRequest extends HTTPService { public function UserDataRequest(URL:String) { super(URL); this.url = URL; this.resultFormat = "e4x"; this.addEventListener(ResultEvent.RESULT, resultListener); this.addEventListener(FaultEvent.FAULT, faultLister); this.send(); } public function faultLister(event:FaultEvent): void { trace(event.fault.message); } public function resultListener(event:ResultEvent): void { UserData.userInfo = (event.result.user) as ArrayCollection; } } } UserData.as ---------------------------------------------------------- package com { import mx.collections.ArrayCollection; public class UserData { public static var userInfo:ArrayCollection = new ArrayCollection; public function UserData(){} } }
