1 Reply Latest reply on Jun 25, 2007 12:13 PM by ntsiii

    displaying and hiding a displayobject depending on a static var.

    Manu Dhanda
      Hii Everybody,

      Here in my web application, I have User and Admin profiles for the users.
      So, depending on the user login id, am selecting who's who.

      And then for the normal user, I want to hide a displayObject from my controlbar. but, I could not think of a way doing it.

      My code for controlbar is as follows:
      [CODE]
      <mx:ControlBar id="cbar1" backgroundColor="0xCCCCCC" paddingTop="0" paddingBottom="0">
      <mx:LinkButton label="Need to Register?" id="registerLink" click="currentState='Register'" />

      <mx:Spacer width="100%" id="mySpacer1"/>
      <mx:Button label="Login" id="loginButton" click="submitLogin(event)"/>
      </mx:ControlBar>
      [/CODE]

      After validating user's login, am changing the state from current to "resultState" and adding the Admin linkbutton to the controlbar.

      [CODE] <mx:State name="resultState" basedOn="">
      <mx:AddChild relativeTo="{loginPanel}" position="before">
      <comp:Results id="myResult" width="100%" height="100%" paddingTop="0" />
      </mx:AddChild>
      <mx:RemoveChild target="{loginPanel}"/>
      <mx:AddChild relativeTo="{myResult}" position="after">
      <mx:ControlBar id="cbar" width="100%" backgroundColor="0xCCCCCC" paddingTop="0" paddingBottom="0">
      <mx:Button label="LogOut" id="logOutButton" click="submitLogOut(event)"/>
      <mx:Spacer id="mySpacer" width="100%"/>
      [COLOR="Red"]<mx:LinkButton id="btnAdmin" label="Admin" click="currentState='stateAdmin'"/>[/COLOR]
      <mx:LinkButton id="btnFav" label="My Favourites" click="currentState='favPage'"/>
      </mx:ControlBar>
      </mx:AddChild>
      </mx:State>
      [/CODE]

      Here, I want to make my selection depending on the user id. whether the user has the admin role or a normal user role.

      Please suggest/guide me to the right direction. Thanks.

      Manu.