![]() |
![]() |
||||||
|
|||||||
| Tags: 2nd, comtainer, data, setting, viewstack |
![]() |
|
|||
|
I have a titlewindow with 2 buttons. And within the titlewindow there is a
viewstack. The viewstack have 2 containers. Button1 click event to switch to container1 and button2 click event to switch to container2. Each container have its own control. Container 1 have textinput and vslider. Container 2 also have textinput and vslider. I could retrieve and set the values of controls in container 1 when button1 is click using viewstack.selectedIndex=0. but am unable to set the values of the control in container 2 when button2 is clicked using viewstack.selectedIndex=1. Got this error for container2. Error #1009: Cannot access a property or method of a null object reference. Appreciate if you could kindly advise. if(DB.variableView == "Cont1") { varEditor.toggleBtn1.selectedIndex = 0; varEditor.viewstack1.selectedIndex = 0; varEditor.txtInitialValue1.text = DB.varInitialValue; } if(DB.variableView == "Cont2"){ varEditor.toggleBtn1.selectedIndex = 1; varEditor.viewstack1.selectedIndex = 1; varEditor.txtInitialValue2.text = DB.varInitialValue; } |
| Sponsored Links |
|
|||
|
"masita18" <webforumsuser@macromedia.com> wrote in message news:g6r666$cr4$1@forums.macromedia.com... >I have a titlewindow with 2 buttons. And within the titlewindow there is a > viewstack. The viewstack have 2 containers. Button1 click event to switch > to > container1 and button2 click event to switch to container2. Each container > have > its own control. Container 1 have textinput and vslider. Container 2 also > have > textinput and vslider. I could retrieve and set the values of controls in > container 1 when button1 is click using viewstack.selectedIndex=0. but am > unable to set the values of the control in container 2 when button2 is > clicked > using viewstack.selectedIndex=1. Got this error for container2. > > Error #1009: Cannot access a property or method of a null object > reference. > > Appreciate if you could kindly advise. > > if(DB.variableView == "Cont1") > { > varEditor.toggleBtn1.selectedIndex = 0; > varEditor.viewstack1.selectedIndex = 0; > > varEditor.txtInitialValue1.text = DB.varInitialValue; > } > if(DB.variableView == "Cont2"){ > > varEditor.toggleBtn1.selectedIndex = 1; > varEditor.viewstack1.selectedIndex = 1; > varEditor.txtInitialValue2.text = DB.varInitialValue; > } You can either put the call to these in creationComplete of the containers in the ViewStack or you can set a flag on change of the ViewStack and then execute this code from updateDisplayList. HTH; Amy |
|
|||
|
I don't think the ids will solve anything Greg. Actually the issue is the
creationPolicy of the components, masita18. Flex automatically creates only the components that are visible so any component on your second container is not available until you access that container. One way to solve this is to change the creationPolicy of your ViewStack to "all", that way Flex will create all the components inside the viewstack, be aware that if you have tons of components your application will load slower. There should be other threads with your same issue around here, some of them have posts with better solutions for your issue. |
![]() |
| Thread Tools | |
| Display Modes | |
|
|
- Contact Us
-|-
Adobe Dreamweaver Forums -|-
Archive -|-
Top -|-Rules/Disclaimer-|-Help/Support-|-Advertise