Skip navigation
Ameya Mogare
Currently Being Moderated

How to get Repeater's runtime height

Apr 1, 2011 4:01 AM

Hi,

 

I have a Repeater that may contain several 'Text' UI components at runtime.

Now I need the total height occupied by these collective text UI elements.

 

Please let me know how to do it.

 

Thanks,

Amey

 
Replies
  • Currently Being Moderated
    Apr 1, 2011 12:24 PM   in reply to Ameya Mogare

    if your code is somewhat like this:

     

    <some mxml container id="my_container">

         <mx:Repeater>

              <mx:Text/>

         </mx:Repeater>

    </some mxml container>

     

    in an event handler write something like this:

     

     

         var repeaterTotalHeight:Number;

         for each (var component:UIComponent in my_container.getChilderen()) {

              repeaterTotalHeight += component.height;

         }

     

    Hope this helps.

     

    T.K.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 5, 2011 3:22 AM   in reply to Ameya Mogare

    Hi,

     

    maybe try skillGroupsVBOX.getChildren() instead of your skillGroupsVBOX.getChilderen() and add import mx.core.UIComponent; in your script?

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 6, 2011 2:41 AM   in reply to Ameya Mogare

              <mx:VBox id="skillGroupsVBOX" horizontalAlign="left" verticalGap="0">
                    <mx:Repeater id="rptSkillGroups" dataProvider="{SkillGroups}">
                        <mx:Text text="{rptSkillGroups.currentItem.sgname}"
                                       click="clickHandler(event.currentTarget.getRepeaterItem());"
                                       mouseOver="clickHandler(event.currentTarget.getRepeaterItem());"
                                       buttonMode="true" useHandCursor="true"
                                       />
                    </mx:Repeater>
                </mx:VBox>

     

     

    If you change

         click="clickHandler(event.currentTarget.getRepeaterItem());"

    by

         click="clickHandler(event.currentTarget);"

     

    Then you will get the Text object and can access the .text property in your

     

         private function clickHandler(item:Object):void {

              item.text;

         }

     

    to get the index in the VBox, just to this with the same code as above :

     

         skillGroupsVBOX.getChildIndex(item as DisplayObject); // item must be the Text object return by event.currentTarget

     

    Hope this is understandable :]

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 6, 2011 6:46 AM   in reply to Ameya Mogare

    you've got something like that :

     

                   <mx:Repeater id="rptSkillGroups" dataProvider="{SkillGroups}">
                        <mx:LinkButton label="somelabel"
                                       click="clickHandler(event.currentTarget);"
                                       />
                    </mx:Repeater>

     

    and you want to get the label of the LinkButton?

     

    In the actionscript :

     

         private function clickHandler(item:Object):void {

              item.label;

         }

     

    I think I don't understand what you want, sorry.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 7, 2011 1:01 AM   in reply to Ameya Mogare

    you tell me if that works

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points