4 Replies Latest reply on Apr 3, 2008 1:14 AM by derm116

    setting percentage width in actionscript

    derm116
      Hi all,

      I'm trying to have a collapsible component on a flex app i'm working on! I've tried using the <mx:Resize> tag as follows

      <mx:Resize id="contract" target="{leftPanel}" widthTo="0"/>
      <mx:Resize id="expand" target="{leftPanel}" widthTo="200"/>

      with leftPanel been a component on my app!
      The above works, kind of - I have to set my right panel to 100% so that when I collapse the left panel the right panel takes up the screen! This is a bit of a messy hack and the problem is that since I've set the widths on my apps as percentages (this is required do the app is scalable) when I expand the leftPanel out again it's a different size!! I don't want to set a static value for the widths as I want it to be scalable!
      I was wondering if anyone knew if I'd be able to set percentages for the widthTo option above?! I couldn't find anything on it so I'm presuming I can't!
      I also tried writing a simple function such as

      public function minimiseScreen():void {
      leftPanel.width = 0;
      rightPanel.width = 100;
      }

      public function maximiseScreen():void {
      leftPanel.width = 30;
      rightPanel.width = 70;
      }

      Again I have a similar problem here that I don't know how to (or if I can?) set percentage values for the widths above? Does anyone know if this is possible? And if so how do I do it?
      Or if it's not possible does anyone know any other way of making components collapsible?

      Any help would really be greatly appreciated!!!
      Thanks in advance,
      Derm