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
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.
Hi,
Thank you for reply.
But this gives me compile time error that -->
Multiple markers at this line:
-1120: Access of undefined property skillGroupsVBOX.
-1046: Type was not found or was not a compile-time constant: UIComponent.
In Script: -
private function clickHandler(item:Object):void {
var cName : String = item.sgname;
item.textDecoration = "underline";
if(cName == "Grp1"){
selectedSkill = 1;
spacerHeight = 0;
}else if(cName == "Grp2"){
selectedSkill = 2;
spacerHeight = 1;
}else if(cName == "Grp3"){
selectedSkill = 3;
spacerHeight = 2;
}
for each (var component:UIComponent in skillGroupsVBOX.getChilderen()) {
repeaterTotalHeight += component.height;
}
}
In MXMX: -
<mx:HBox id="skillHbox" horizontalAlign="left" >
<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>
<mx:VBox id="skillDescVBOX" >
<mx:ViewStack id="skillDescViewStack" selectedIndex="{selectedSkill}" >
<!-- child 0 -->
<mx:VBox id="emptyVBox" showEffect="{wipeRight}" hideEffect="{wipeLeft}">
</mx:VBox>
<!-- child 1 -->
<mx:VBox id="Act_A_VBox" showEffect="{wipeRight}" hideEffect="{wipeLeft}" >
<mx:Spacer height="{spacerHeight}"/>
<mx:Repeater id="rptAct_A" dataProvider="{Act_A}">
<mx:Text htmlText="{rptAct_A.currentItem.act}" width="90%" />
</mx:Repeater>
</mx:VBox>
<!-- child 2 -->
<mx:VBox id="Act_B_VBox" showEffect="{wipeRight}" hideEffect="{wipeLeft}">
<mx:Repeater id="rpt_B" dataProvider="{Act_B}">
<mx:Text htmlText="{rpt_B.currentItem.act}" width="90%" />
</mx:Repeater>
</mx:VBox>
<!-- child 3 -->
<mx:VBox id="Act_C_VBox" showEffect="{wipeRight}" hideEffect="{wipeLeft}">
<mx:Repeater id="rpt_C" dataProvider="{Act_C}">
<mx:Text htmlText="{rpt_C.currentItem.act}" width="90%" />
</mx:Repeater>
</mx:VBox>
</mx:ViewStack>
</mx:VBox>
</mx:HBox>
Hi,
Thanks for valuable reply.
Yes, it worked with the way you suggested.
How can I get the text property of repeated text UI elements while in loop?
I have a Vbox which has a repeater that repeates Text UI elements.
Now on mouseOver of a TextUI element, I want to know what is its index in Vbox?
How do I find it out?
Please help.
Thanks,
Amey
<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 :]
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.
Ah ok. I got what you want to say.
My repeater code is like: -
<mx:Repeater id="rptSkillGroups" dataProvider="{SkillGroups}">
<mx:LinkButton label="{rptSkillGroups.currentItem.sgname}"
click="clickHandler(event.currentTarget);"
/>
</mx:Repeater>
Now in event handler, to get current labelText, I would write, "item.getRepeaterItem().sgname;" , correct?
North America
Europe, Middle East and Africa
Asia Pacific