You can avoid the currentState issue by setting it in your mx:Application tag:

<mx:Application currentState="leftPanel"> 

You shouldn't need curly braces when defining event handlers in the tags, only 
when you're setting properties.

>It appears that, until you set it, the base state is null.  Change 
>your first condition to something like this:
>
>if(this.currentState != null && this.currentState != '')
>
>  I'm not sure if it would cause an error, but the click code was not 
>enclosed in curly brackets.
>  I also moved the Script block to the top, although that should make 
>no difference.
>
>I tried to add my full code to the codeshare, but got an error.  So, 
>here is the text (with my debugging output )
>
>
><?xml version="1.0" encoding="utf-8"?>
>  <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; 
>layout="horizontal">
>
>      <mx:Script>
>          <![CDATA[
>
>                 import mx.controls.Alert
>              public function toggleLeft():void
>              {
>                 Alert.show('A' + this.currentState + 'A');
>                  if(this.currentState != null && this.currentState != '')
>                  {
>                         Alert.show('default');
>                      this.currentState = '';
>                  }
>                  else
>                  {
>                         Alert.show('hide left');
>                      this.currentState = 'hide_left';
>                  }
>              }
>              public function toggleRight():void
>              {
>                 Alert.show(this.currentState);
>                  if(this.currentState != null && this.currentState != '')
>                  {
>                      this.currentState = '';
>                  }
>                  else
>                  {
>                      this.currentState = 'hide_right';
>                  }
>              }
>          ]]>
>      </mx:Script>
>
>      <mx:states>
>          <mx:State name="hide_left">
>              <mx:SetProperty target="{left_panel}" name="visible" 
>value="false" />
>              <mx:SetProperty target="{right_panel}" name="width" 
>value="100%" />
>          </mx:State>
>          <mx:State name="hide_right">
>              <mx:SetProperty target="{right_panel}" name="visible" 
>value="false" />
>              <mx:SetProperty target="{left_panel}" name="width" 
>value="100%" />
>          </mx:State>
>      </mx:states>
>      <mx:HBox width="100%" id="container" name="container">
>          <mx:Panel id="left_panel" name="left_panel" title="LEFT 
>PANEL" width="50%" height="100%">
>              <mx:Label text="This is the left panel." />
>              <mx:ControlBar>
>                  <mx:Button label="Toggle LEFT Panel" 
>click="{toggleLeft()}" />
>                  <mx:Button label="Toggle RIGHT Panel" 
>click="{toggleRight()}" />
>              </mx:ControlBar>
>          </mx:Panel>
>          <mx:Panel id="right_panel" name="right_panel" title="RIGHT 
>PANEL" width="50%" height="100%">
>              <mx:Label text="This is the right panel." />
>              <mx:ControlBar>
>                  <mx:Button label="Toggle LEFT Panel" 
>click="{toggleLeft()}" />
>                  <mx:Button label="Toggle RIGHT Panel" 
>click="{toggleRight()}" />
>              </mx:ControlBar>
>          </mx:Panel>
>      </mx:HBox>
>
>  </mx:Application>
>
>
>
>At 09:30 AM 1/29/2007, you wrote:
>
>
>
>
>--
>Jeffry Houser, Software Developer, Writer, Songwriter, Recording Engineer
>AIM: Reboog711  | Phone: 1-203-379-0773
>--
>My Company: <http://www.dot-com-it.com>
>My Podcast: <http://www.theflexshow.com>
>My Blog: <http://www.jeffryhouser.com>
>Connecticut Macromedia User Group: <http://www.ctmug.com>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Upgrade to Adobe ColdFusion MX7 
Experience Flex 2 & MX7 integration & create powerful cross-platform RIAs 
http:http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU

Archive: http://www.houseoffusion.com/groups/Flex/message.cfm/messageid:3516
Subscription: http://www.houseoffusion.com/groups/Flex/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.37

Reply via email to