Actually, I do this all the time with a viewstack. The way I do it is I have
the main application check the security and setup a security level
parameter. Then, I pass this secLevel to the component that contains the
viewstack. In the viewstack component, each view in the viewstack is its own
component, so you can use the includeInLayout and visible properties of the
component to show it or not show it based on the value of secLevel. Works
like a charm.
Main.mxml
<mx:states>
<mx:State name="checkSecurity">
<mx:AddChild>
...show only a progress bar to the user while checking the security in
ActionScript
...you setup the secLevel
</mx:AddChild>
</mx:State>
<mx:State name="mainApplication">
<mx:AddChild>
<comps:MainApp id="mainApp" secLevel="{this.secLevel}"/>
</mx:AddChild>
</mx:State>
</mx:states>
MainApp.mxml
<mx:ToggleButtonBar id="mainButtonBar" dataProvider="{vs}"/>
<mx:ViewStack id="vs">
<comps:FirstButton id="first"/>
<comps:SecondButton id="second"/>
<comps:ThirdButton id="third"/>
<comps:Setup id="setup" includeInLayout="{(secLevel == 0)?true:false}"
visible="{(secLevel == 0)?true:false}"/>
</mx:ViewStack>
And, voila, you only see the Setup button if you're secLevel is 0.
HTH,
~randy
_____
From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Tracy Spratt
Sent: Wednesday, July 30, 2008 11:18 AM
To: [email protected]
Subject: RE: [flexcoders] permission based ui
Do not use the ViewStack as the dataProvider. Build the navigation system’s
dataProvider as needed for the curent user, include the view index in each
item. On click, assign the item.viewIndex property value to the
viewStack.selectedI-tem.
Tracy
_____
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Derrick Anderson
Sent: Wednesday, July 30, 2008 11:55 AM
To: [EMAIL PROTECTED]
Subject: [flexcoders] permission based ui
hi, i have my main UI setup with a ToggleButtonBar whos dataprovider is a
viewstack. I need to incorporate permissions into my application, some
users won't have access to the 'Setup' section for example- is there an easy
way to do this or do i need to subclass ToggleButtonBar? how do you all
handle permissions in mxml layout? i have many examples of this, form
sections that are permission based and such, I don't know the best way to
handle it.
thanks,
derrick anderson
No virus found in this outgoing message.
Checked by AVG.
Version: 7.5.523 / Virus Database: 270.5.8/1582 - Release Date: 7/30/2008
6:37 PM