code_junkie

Flex - Binding ViewStack selectedChild Property Using a String Value

Nov 12th, 2011
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.95 KB | None | 0 0
  1. TypeError: Error #2007: Parameter child must be non-null.
  2. at flash.display::DisplayObjectContainer/getChildIndex()
  3. at mx.core::Container/getChildIndex()[E:dev3.0.xframeworksprojectsframeworksrcmxcoreContainer.as:2409]
  4. at mx.containers::ViewStack/set selectedChild()[E:dev3.0.xframeworksprojectsframeworksrcmxcontainersViewStack.as:557]
  5.  
  6.  
  7. <?xml version="1.0" encoding="utf-8"?>
  8. <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
  9. <mx:Script>
  10. <![CDATA[
  11. [Bindable]
  12. private var targetViewName:String = "content";
  13. ]]>
  14. </mx:Script>
  15.  
  16. <mx:ViewStack id="viewStack" width="100%" height="100%"
  17. selectedChild="{Container(viewStack.getChildByName(targetViewName))}">
  18. <mx:Panel id="welcome" width="100%" height="100%" />
  19.  
  20. <mx:Panel id="content" width="100%" height="100%" />
  21. </mx:ViewStack>
  22. </mx:Application>
  23.  
  24. <?xml version="1.0" encoding="utf-8"?>
  25. <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
  26. <mx:Script>
  27. <![CDATA[
  28. import mx.core.Container;
  29. [Bindable]
  30. private var targetViewName:String = "content";
  31.  
  32. private function onClick() : void
  33. {
  34. viewStack.selectedChild = Container(viewStack.getChildByName(targetViewName)) ;
  35. }
  36. ]]>
  37. </mx:Script>
  38.  
  39. <mx:ViewStack id="viewStack" width="100%" height="100%" >
  40. <mx:Panel id="welcome" width="100%" height="100%" title="welcome"/>
  41.  
  42. <mx:Panel id="content" width="100%" height="100%" title="content" />
  43. </mx:ViewStack>
  44.  
  45. <mx:Button click="onClick()" label="click" />
  46.  
  47. </mx:Application>
  48.  
  49. selectedChild="{this[targetViewName]}">
  50.  
  51. <?xml version="1.0" encoding="utf-8"?>
  52. <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
  53. <mx:Script>
  54. <![CDATA[
  55. [Bindable]
  56. private var targetViewName:String = "content";
  57. ]]>
  58. </mx:Script>
  59.  
  60. <mx:TabNavigator id="viewStack" width="100%" height="100%" creationPolicy="all"
  61. selectedChild="{this[targetViewName]}">
  62. <mx:Panel id="welcome" width="100%" height="100%" label="welcome" />
  63.  
  64. <mx:Panel id="content" width="100%" height="100%" label="content" />
  65. </mx:TabNavigator>
  66. </mx:Application>
  67.  
  68. <mx:TabNavigator id="viewStack" width="100%" height="100%" creationPolicy="all" >
  69. <mx:Panel id="welcome" width="100%" height="100%" label="welcome" />
  70.  
  71. <mx:Panel id="content" width="100%" height="100%" label="content" addedToStage="viewStack.selectedChild = this" />
  72. </mx:TabNavigator>
  73.  
  74. <mx:Script>
  75. <![CDATA[
  76. import models.ModelLocator;
  77.  
  78. [Bindable]
  79. private var model:ModelLocator = ModelLocator.getInstance();
  80. ]]>
  81. </mx:Script>
  82.  
  83. <mx:ViewStack id="videoViewStack" width="100%" height="100%" selectedChild="{this[model._videoViewStack]}" >
  84. <viewsVideos:AllVideos id="AllVideos" label="Videos"/>
  85. <viewsVideos:MainVideo id="MainVideo" label="Video"/>
  86. </mx:ViewStack>
Add Comment
Please, Sign In to add comment