2 Replies Latest reply on Apr 1, 2008 4:03 PM by ntsiii

    Permissions for Tabs

    kdennis4 Level 1
      I have creationComplete="initApp()" within my <mx:Application>

      I then have:

      private function initApp():void {
      var userPermissions:String = "Client";
      }

      I will eventually be pulling data from a call to a table, but in the meantime I would like to hardcode "if not equal to Manager" don't show this tab. Does anyone know if this is possible, and what to add to the following as an example:

      <mx:Canvas fontFamily="Gotham" label="Project Status" width="100%" height="100%" backgroundColor="#e7ebf1" id="Status" backgroundAlpha="#dde0e6">

      Thank you in advance for your replys!
        • 1. Re: Permissions for Tabs
          Gregory Lafrance Level 6
          Do you mean you want to determine the number of tabs displayed, and thus selectable in a TabNavigator container? In that case you could call a function to create and add the TabNavigator from initApp(), passing the result of "if not equal to Manager". In that other function construct the TabNavigator with tabs appropriate for the user permissions.
          • 2. Re: Permissions for Tabs
            ntsiii Level 3
            Yes, as far as I know, there is no way to programatically "hide" a tab. You need to add and remove the children programatically.

            But I suggest using a ViewStack and a dynamic TabBar instead. Do NOT use the ViewStack as the TabBar dataProvider. that will produce the same problem you face now. Instead, use a repeater to create the TabBar tabs. Use the client type string to filter the dataProvider to return only the items that are permitted to the user. Repeater will do the rest. Make sure there is an index value in the data items that corresponds to the index of the ViewStack. That way you can simply set the VS.selectedIndex.

            Tracy