In order to improve the start-up performance of complex applications, many Flex containers, like ViewStack and TabNavigator use a feature called "deferred instantiation". This means that the child views of such containers are not instantiated until the user navigates to that child view.
So in your case, Canvas "bbb" does not exist until you have viewed it the first time. The best solution is to craft the app to use binding and event driven code to initialize/update the child components, instead of attempting to set the values from the "outside". A quick and dirty fix is to set the creationPolicy="all" on the ViewStack. This forces all the child components to be instantiated when the app loads. This can have a negative effect on the app load performance. Tracy ________________________________ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of j_hora Sent: Sunday, January 14, 2007 8:45 AM To: [email protected] Subject: [flexcoders] Problem with viewstack in Flex 2.0 ActionScript not search element by id. Hallo, i start with Flex2 and have this problem. ActionScript not search Label by id in the second Canvas in ViewStack. Application start with error TypeError: Error #1009: Cannot access a property or method of a null object reference. Id "labela" search OK, but "labelb" is for the function "invisible". What's wrong? My application: <?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" creationComplete="start();"> <mx:Script> <![CDATA[ public function start():void { labela.text = "new text A"; labelb.text = "new text B"; } ]]> </mx:Script> <mx:TabBar height="30" width="200" id="tab_menu" dataProvider="stack1" > </mx:TabBar> <mx:ViewStack x="0" y="40" width="250" height="100" borderStyle="solid" id="stack1"> <mx:Canvas label="aaa"> <mx:Label width="200" id="labela" text="old text A"/> </mx:Canvas> <mx:Canvas label="bbb"> <mx:Label width="200" id="labelb" text="old text B"/> </mx:Canvas> </mx:ViewStack> </mx:Application> Very thanks for help Jan Hora

