3 Replies Latest reply on Jun 5, 2006 5:15 PM by uday.shankar

    State Change

      Hi All,
      I am newbie to flex. Am still trying to get the basic stuff working :). I have just created a screen with 2 states, onclick of a button, I want to change to state2. Its woking fine when I try it using the MXML way. I am lincuding the code here. Sure it must be something simple that i am overlooking, but then... :)

      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute">
      import mx.controls.Alert;

      private var filterStatus:int = 0;
      private function FilterDialog():void{
      if(filterStatus == 0){
      else if(filterStatus == 1){

      private function showFilterDialog():void{
      filterStatus = 1;

      private function hideFilterDialog():void{
      Alert.show('Hide Window');
      filterStatus = 0;

      <mx:State name="stFilterDialog">
      <mx:SetProperty target="{cvsFilter}" name="height" value="15%"/>
      <mx:SetStyle target="{lbtnShowFilter}" name="verticalCenter"/>
      <mx:SetProperty target="{cvsLogMessageGrid}" name="height" value="85%"/>
      <mx:SetStyle target="{cvsLogMessageGrid}" name="bottom" value="0"/>
      <mx:SetStyle target="{cvsLogMessageGrid}" name="top"/>
      <mx:SetStyle target="{cvsLogMessageGrid}" name="left"/>
      <mx:SetStyle target="{cvsLogMessageGrid}" name="horizontalCenter" value="0"/>
      <mx:Panel width="100%" height="100%" layout="absolute" id="pnlLogList" title="System logs and messages" y="0" x="0">
      <mx:Canvas width="100%" height="31" cornerRadius="0" borderStyle="inset" borderThickness="1" top="0" horizontalCenter="0" backgroundColor="#f8f8f8" id="cvsFilter">
      <mx:LinkButton label="Show Filter" id="lbtnShowFilter" click="FilterDialog()" right="5" top="2"/>
      <mx:Canvas width="100%" height="100%" left="0" top="30" id="cvsLogMessageGrid" resizeEffect="Resize" >
      <mx:DataGrid width="100%" height="100%" horizontalCenter="0" id="dgrdLogMessages" verticalCenter="0">


        • 1. Re: State Change
          Level 7
          Hi ushankar,

          > private function showFilterDialog():void{
          > cvsFilter.setCurrentState("stFilterDialog",true);
          > filterStatus = 1;
          > }

          Instead of cvsFilter.setCurrentState("stFilterDialog", true"), I think
          you just want to say:

          currentState = "stFilterDialog";

          The states as you've defined them are a property of the main
          application, not of cvsFilter.

          Hope this helps.

          Flex Builder team
          • 2. Re: State Change
            uday.shankar Level 1
            Hi All, I fiddled around with those more and found that it works if I change the
            cvsFilter.setCurrentState("stFilterDialog",true); to currentState = "stFilterDialog";

            I guess thius because the states I have defined is not under the canvas. So, it wont work if I try to access it through the canvas which was what I was trying to do inititally. :)
            • 3. Re: State Change
              uday.shankar Level 1
              Hey.... Narcis has already answered it :). Thanx buddy.... :)