2 Replies Latest reply on Sep 24, 2008 7:17 AM by ANewFlexUser

    dynamically setting the size of the vbox

    Merlyn_MM
      Here is my code and I am trying to get the sliding panel effect to fit the sub data, how can I resize to fit all the labels instead of a specific number. In this case I set heightTo=300, is there anyway that I can dynamically set this number based on the data returned by the webservice? or is there anyway that I can do this?

      Thanks!


      public function categorySummarySelected(index):void{
      Alert.show(index);

      for(var i=0; i< catInfo.length; i++){

      if(i == index){
      slideOpen(i);

      //
      }
      else
      {

      slideClosed(i);

      }

      }

      }



      private function slideOpen(index){

      var e = new mx.effects.Resize(summary[index]);
      e.heightTo = 120;

      e.duration = 300;

      e.play();

      }



      private function slideClosed(index){

      var e = new mx.effects.Resize(summary[index]);
      e.heightTo = 0;

      e.duration = 300;

      e.play();

      }
      ]]>

      </mx:Script>

      <mx:Canvas x="0" y="0" width="100%" height="100%" id="canvas1" label="OnCor" backgroundColor="#FFFFFF">
      <mx:HBox x="0" y="0" width="80%" height="100%" backgroundColor="#FFFFFF">
      <mx:Image width="1100" height="1000" source="OnCor-Map.jpg"/>
      <mx:Label text="Label"/>
      </mx:HBox>


      </mx:Canvas>
      <mx:VBox id="myvbox" x="1070" y="0" width="245" height="100%">

      <mx:Label id="idLabel" text="ID Here"/>



      <mx:Repeater id="myRepeater" dataProvider="{catInfo}">

      <mx:VBox id="bigbox">

      <mx:Button label="{myRepeater.currentItem.CATEGORYDESC}" fillColors="[#ffcc00,#ffcc00]"
      data="{myRepeater.currentItem}"
      click="displayId(event.target.getRepeaterItem())" mouseUp="categorySummarySelected(event.target.repeaterIndices[0])"/>

      </mx:VBox>

      <mx:VBox id="summary">

      <mx:Repeater id="myrep" dataProvider="{SubcatInfo1}">

      <mx:Label text="{myrep.currentItem.CATEGORYDESC}"/>

      </mx:Repeater>

      </mx:VBox>


      </mx:Repeater>

      </mx:VBox>
        • 1. Re: dynamically setting the size of the vbox
          ANewFlexUser Level 1
          I don't know the specifics of WebServices, but I can tell you how I would do it with DataServices, and WebServices contains the result event, so I have to think something similar to this will work.

          The basic idea is to add an event listener to your service, so when it's done doing its thing, you can grab the information you need and store it in a local variable. Then you simply modify your slideOpen function to point at that local variable, rather than a constant value. Now knowing how your WebService returns data, I can't be too helpful with that portion, for which I apologize.

          It's extremely important to remember to remove the EventListener in the handler function, so that you don't end up overloading your stack when your Web Service is called multiple times.

          Anyways, that's how I would handle it with a DataService; I hope the general idea is useful, even if the specific details vary a little. Code is attached.
          • 2. Re: dynamically setting the size of the vbox
            ANewFlexUser Level 1
            Also, as an addendum, if you're placing calls to multiple WebServices, you're going to want to consider either: 1. making serperate event handling functions for each Service, so you don't remove the eventListener from the wrong Service, or 2. checking the target of the result event, so you only remove the eventListener from the Service that issued the event.