PDA

View Full Version : controlling scroll bars


persiankamran
11-07-2008, 05:27 AM
folks i posted a similar kind of question earlier but here is the changed question.

Let say i have one mainApplication container and in that container i have one UIComponent and then 2 text Areas in the UIComponent.

I have disabled the scroll policy of both the textAreas. What i want is that when the text height in any textarea changes, i should be able to check whether the changed height is greater than currentHeight and if yes.. it should put the scroll on the mainApplication.. so that mainApplication is controlling the scroll for both the textAreas.

For that i added a "change" event to the textArea1 and then called a function..

But i dont know how can i compare the changed height versus the current Height because i have given the currentHeight as 100%.. and then how to put the scrolling on the mainApplication container


Can any one help??

persiankamran
11-07-2008, 05:29 AM
CONTD,

one thing i forgot to mention is that i tried to set the textArea height to an arbitrary value but

textarea.textHeight is readonly!!!

Sly_cardinal
11-07-2008, 10:28 AM
The textHeight property is used to determine the height of the text within a text control. The height property is the height of the text control (inherited from the DisplayObject class).


<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
width="800" height="200">

<mx:Script>
<![CDATA[
import flash.events.Event;
import mx.controls.TextArea;

private function textChangeHandler(event:Event):void
{
var textField:TextArea = TextArea(event.target);

if (textField.textHeight > textField.height)
{
text1.height = textField.textHeight;
text2.height = textField.textHeight;
}
}

]]>
</mx:Script>

<mx:Canvas width="100%" height="100%">

<mx:HBox width="95%" height="100%">
<mx:TextArea id="text1" verticalScrollPolicy="off" width="50%" height="100%"
change="textChangeHandler(event)" />

<mx:TextArea id="text2" verticalScrollPolicy="off" width="50%" height="100%"
change="textChangeHandler(event)" />
</mx:HBox>

</mx:Canvas>


</mx:Application>