Flex中如何利用getTabAt函数遍历TabNavigator容器的各个Tab,并且通过labelPlacement属性设置标签位置

main.mxml

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <mx:Applicationname="TabNavigator_getTabAt_labelPlacement_test"
  3. xmlns:mx="http://www.adobe.com/2006/mxml"
  4. layout="vertical"
  5. verticalAlign="middle"
  6. backgroundColor="white">
  7. <mx:Script>
  8. <![CDATA[
  9. import mx.controls.tabBarClasses.Tab;
  10. private function init():void {
  11. var tab:Tab;
  12. var idx:uint;
  13. var len:uint = tabNavigator.numChildren;
  14. for (idx=0; idx<len; idx++) {
  15. tab = tabNavigator.getTabAt(idx) as Tab;
  16. tab.labelPlacement = tab.label;
  17. }
  18. }
  19. ]]>
  20. </mx:Script>
  21. <mx:TabNavigatorid="tabNavigator"
  22. tabWidth="150"
  23. tabHeight="60"
  24. height="100%"
  25. creationComplete="init();">
  26. <mx:VBoxlabel="left"
  27. icon="@Embed('assets/arrow_left.png')">
  28. <mx:Labeltext="labelPlacement = 'left'" />
  29. </mx:VBox>
  30. <mx:VBoxlabel="right"
  31. icon="@Embed('assets/arrow_right.png')">
  32. <mx:Labeltext="labelPlacement = 'right'" />
  33. </mx:VBox>
  34. <mx:VBoxlabel="top"
  35. icon="@Embed('assets/arrow_up.png')">
  36. <mx:Labeltext="labelPlacement = 'top'" />
  37. </mx:VBox>
  38. <mx:VBoxlabel="bottom"
  39. icon="@Embed('assets/arrow_down.png')">
  40. <mx:Labeltext="labelPlacement = 'bottom'" />
  41. </mx:VBox>
  42. </mx:TabNavigator>
  43. </mx:Application>

你可能感兴趣的:(xml,Flex,UP,Adobe)