Hey Brian, sorry about the 1 liner.  Basically this:

<mx:TextArea id="my_ta" change="my_ta.vPosition = my_ta.maxVPosition" />

Is the same as:

import mx.controls.TextArea;
createChild ( TextArea, "my_ta" );
my_ta.addEventListener ( "change", Delegate.create(this, anonFunction));
function anonFunction(event:Object):Void
{
  my_ta.vPosition = my_ta.maxVPosition;
}

MXML tags go outside of your script tags.

----- Original Message ----- 
From: "Brian Lesser" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Thursday, February 02, 2006 7:38 AM
Subject: Re: [flexcoders] Re: Scrolling a TextArea to the bottom?


Hi Gordon,
I wrote too soon! This DOES work (with a really minor rendering problem) :

public function writeln(msg:String):void{
            traceArea.text += msg + "\n";
            traceArea.validateNow();
            traceArea.vPosition = traceArea.maxVPosition;
}

The minor problem is that the first time I ran the app and the TextArea
scrolled to the bottom, the scroll bar elevator appeared briefly well
below the a scroll bar area. I can't make it do it all the time either
so I'm much further ahead.
Thanks again,
-Brian

Brian Lesser wrote:

>Hi Gordon,
>Thanks for the suggestion, even though I couldn't get it to work, I
>really appreciate your taking the time to explain how things work. It's
>good to know that stuff.
>
>Here's what I tried that didn't work:
>
>public function writeln(msg:String):void{
>            traceArea.text += msg + "\n";
>            traceArea.vPosition = traceArea.maxVPosition;
>            traceArea.validateNow();
>}
>
>Earlier Jesse suggested the line below but I have no idea (being new to
>Flex) how to incorporate that into a function:
>
><mx:TextArea id="my_ta" change="my_ta.vPosition = my_ta.maxVPosition" />
>
>Any ideas how I could get reliable scrolling to the bottom of a text area 
>with the least amount of code/complexity?
>
>Yours truly,
>-Brian
>
>
>
>Gordon Smith wrote:
>
>
>
>>Try calling traceArea.validateNow() after setting the text.
>>
>>Here is some background about this...
>>
>>Flex relies heavily on "invalidation": you set a property but it doesn't
>>take effect until later. That allows you, for example, to set a bunch of
>>properties and have a component only redraw once, instead of redrawing
>>after each property is changed.
>>
>>There are three invalidation APIs on a UIComponent
>>
>>   invalidateProperties();
>>   invalidateSize();
>>   invalidateDisplayList();
>>
>>and most property setters call one or more of these. For example, the
>>setter for the 'text' property of a TextArea calls
>>invalidateProperties() and invalidateDisplayList().
>>
>>These APIs push the component onto various queues that the LayoutManager
>>maintains.
>>
>>When the Flash Player is about to render the tree of DisplayObjects onto
>>the screen, we "validate" the components in these queues by calling
>>three "validation" APIs, which bring the component up-to-date:
>>
>>   validateProperties()  -> commitProperties()
>>   validateSize()        -> measure()
>>   validateDisplayList() -> updateDisplayList()
>>
>>The call to commitProperties() pushes the text into the underlying Flash
>>TextField.
>>
>>You can cause these three methods to be called prematurely (i.e., before
>>the player is about to render) by calling validateNow() on the
>>component.
>>
>>- Gordon
>>
>>
>>-----Original Message-----
>>From: [email protected] [mailto:[EMAIL PROTECTED] On
>>Behalf Of Brian Lesser
>>Sent: Wednesday, February 01, 2006 9:24 PM
>>To: [email protected]
>>Subject: Re: [flexcoders] Re: Scrolling a TextArea to the bottom?
>>
>>Thanks Mac,
>>You know, I just assumed it would work in Flex. In Flash I used to be
>>able to call redraw() right after setting the vPosition property and it
>>would work ok. I don't suppose there is a simple one liner that does the
>>
>>job in Flex??
>>Yours truly,
>>-Brian
>>
>>vardpenguin wrote:
>>
>>
>>
>>
>>
>>>You're doing it correctly, the problem is that when you set the
>>>vPosition, the 'msg' string has not been fully loaded into the
>>>textArea yet.
>>>
>>>You need to do some sort of check to make sure the textArea content
>>>change has been completed, or wait a few moments before you set
>>>
>>>
>>>
>>>
>>vPosition.
>>
>>
>>
>>
>>>-Mac
>>>
>>>
>>>--- In [email protected], Brian Lesser <[EMAIL PROTECTED]> wrote:
>>>
>>>
>>>
>>>
>>>
>>>
>>>>Possibly really dumb question but shouldn't this scroll a TextArea to
>>>>the bottom:
>>>>
>>>>public function writeln(msg:String):void{
>>>>     traceArea.text += msg + "\n";
>>>>     traceArea.vPosition = traceArea.maxVPosition;
>>>>}
>>>>
>>>>Where traceArea is a TextArea.
>>>>
>>>>It doesn't seem to work for me in Flex Beta 1.
>>>>
>>>>Yours truly,
>>>>-Brian
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>--
>>>Flexcoders Mailing List
>>>FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
>>>Search Archives:
>>>
>>>
>>>
>>>
>>http://www.mail-archive.com/flexcoders%40yahoogroups.com
>>
>>
>>
>>
>>>Yahoo! Groups Links
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>
>>
>>
>>
>
>
>
>


-- 
______________________________________________________________________
Brian Lesser
Assistant Director, Teaching and Technology Support
Computing and Communications Services
Ryerson University
350 Victoria St.
Toronto, Ontario                   Phone: (416) 979-5000 ext. 6835
M5B 2K3                            Fax: (416) 979-5220
Office: AB48D                      E-mail: [EMAIL PROTECTED]
(Enter through LB66)               Web: http://www.ryerson.ca/~blesser
______________________________________________________________________



--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
Yahoo! Groups Links








--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to