Link to home
Start Free TrialLog in
Avatar of Jay Roy
Jay RoyFlag for United States of America

asked on

Expand-Collapse on label click

hi guys

I am trying to impliment a expand-collapse on a label. When label (inside HBox) is clicked, i want the HBox to expand-collapse.

<mx:VBox width="96%" styleName="responseBox">

<mx:HBox id="outerHbox1" width="100%" maxHeight="261">  
<mx:Label text="Question 25:  Components and Servicess:" creationComplete="expcollLabel(event)" />       
</mx:HBox>

<mx:HBox styleName="projAnswerBox"  width="100%">
<mx:DataGrid id="dataGrid" width="862">
<mx:columns>
<mx:DataGridColumn headerText="List the name of project" />
<mx:DataGridColumn headerText="Modification" />
<mx:DataGridColumn headerText="Company benefits"  />                   
</mx:columns>
</mx:DataGrid>
</mx:HBox>      
            
</mx:VBox>

private function expcollLabel(event:Event):void {                        
var label:Label = event.currentTarget as Label;
var titleBar:UIComponent = rte.mx_internal::getTitleTextField();  --getting error here. ::getTitleBar not found on mx.controls.Label
titleBar.addEventListener(MouseEvent.CLICK, expandCollapseLabel);
expandCollapseLabel(event);
}

private function expandCollapseLabel(event:Event):void{
var label:Label;
if(event.currentTarget is Label){
label = event.currentTarget as Label;
}else{
label = event.currentTarget.parent as Label;
}
var headerHeight:uint = rte.mx_internal::getHeaderHeightProxy();
rte.height = (rte.height == headerHeight ? rte.maxHeight : headerHeight);
}      


Am i doing this correctly?
Any help will be appreciated.

thanks.
ASKER CERTIFIED SOLUTION
Avatar of dgofman
dgofman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If you want to collapse an aswerBox your code should be like this or you have to change visibility and includeInLayout parameters

<fx:Script>
		<![CDATA[
			private function expandCollapseLabel(event:Event):void{
				answerBox.maxHeight = (answerBox.maxHeight == 0 ? NaN : 0);
			}
		]]>
	</fx:Script>
	<mx:VBox width="96%" styleName="responseBox">
		<mx:HBox id="outerHbox1" width="100%" maxHeight="261">  
			<mx:Label text="Question 25:  Components and Servicess:" click="expandCollapseLabel(event)" />
		</mx:HBox>
		<mx:HBox id="answerBox" styleName="projAnswerBox"  width="100%">
			<mx:DataGrid id="dataGrid" width="862">
				<mx:columns>
					<mx:DataGridColumn headerText="List the name of project" />
					<mx:DataGridColumn headerText="Modification" />
					<mx:DataGridColumn headerText="Company benefits"  />                   
				</mx:columns>
			</mx:DataGrid> 
		</mx:HBox> 
	</mx:VBox>

Open in new window

Avatar of Jay Roy

ASKER

>>>I think I wrote this code
yep, its your code, i was just playing with it and trying to make it work :)
thanks very much brother, you helped me a lot. I am still learning flex. Let me know if i can help you anyway. I know little java, OOPS and spring.

Avatar of Jay Roy

ASKER

hi dgofman:

can you please help me with this question when you have time.

https://www.experts-exchange.com/questions/26981918/populating-data-in-richtext-from-a-For-loop.html?anchorAnswerId=35484128#a35484128

thanks in advance