Thanks Tracy!! CreationPolicy: Dont leave home without it! brad -----Original Message----- From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Tracy Spratt Sent: Friday, February 15, 2008 2:32 PM To: [email protected] Subject: RE: [flexcoders] Component Visbility in ViewStack
You are not understanding "deferred instantiation" I'd wager the component that works is the "0" index child of the ViewStack. The child componets of a ViewStack, or TabNavigator, are not rendererd (do not exist) until a user navigates to that view. This is to improve startup response by not requiring that the entire application be rendered before the user can interact with it. So you can't programatically reference the a child of a ViewStack until it is viewed. Best practice is to use an event, like show, or creationComplete to fetch the data into the component, instead of trying to set it from the "outside". So have your resultHandler set a Bindable instance variable with the data, then bind to that in the components. Search the Archive or google for "deferred instantiation" and "creationPolicy" for more info. Tracy _____ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Brad Bueche Sent: Friday, February 15, 2008 1:38 PM To: [email protected] Subject: [flexcoders] Component Visbility in ViewStack I am trying to assign a value to a component property in my actionscript. If the component is NOT in a viewstack, everything works fine. If the component IS in the viewstack, all I get are null object reference errors. I also get the warning "unable to bind to property 'month' on class 'XML' (class is not an IEventDispatcher). The line it blows up on is "bucketComponent.month_number = "9"; I have another component in the same program IN the viewstack that does not have this problem. And I'm doing essentially the same thing in the component that works. In the component that does not work I do the following: [Bindable] public var month_number:String = '6'; // this is just a default setting private var xmlService:HTTPService new HTTPService (); private function loadXML():void { xmlSerivce.url = "http//longurl/generateXM.php" xmlService.resultFormat = "e4X" xmlService.addEventListener(ResultEvent.RESULT, resultHandler); xmlService.send(); } private function resultHandler(event:ResultEvent):void { linechart.dataProvider = event.result.month[month_number].day; } What am I not understanding here? brad

