PDA

View Full Version : Automatically Scrolling Text Using The Scrollbar


David Heath
11-24-2005, 10:17 AM
Hello there,

At the moment I have a single text box ('Section1Text_txt') which has a scrollbar component linked to it ('cmpScrollBar'). The text box is linked to an XML file which feeds paragraphs into the box sequentially as the user moves forward in the movie. As you can image, the text box fills up pretty quickly, and it isn't long before the user needs to scroll down to see the newly added text.

At the moment I have the following line of code to automatically scroll the text box to the bottom, so that the user can easily read the newest text added:

section1Text_txt.scroll +=25;

This seems to work fine, except for when the text almost causes the scrollbar to appear (it is invisible unless needed), in which case the scrollbar becomes invisible for a half second or so before disappearing again. This is not ideal at all, so I am asking if there is a way around this, or if there is an alternative way of approaching this problem.

I tried adding a white graphic symbol over the top of the scrollbar (covering it up)), and causing it to only become invisible (thus revealing the scrollbar) if the scrollbar itself is needed, but the scrollbar component doesn't seem to recognise the '.visible' caommand and so this didn't work at all.

Any ideas?

shassouneh
11-24-2005, 05:32 PM
OK a couple of quick clarifications.
.visible is not a command. Its a property. And the preoper syntax for it is _visible (the underscore is a must). So you might try something like

cmpScrollBar._visible = false;

Also, May I suggest that you force your users to wait say 10 or 15 seconds or until say 30% of the text has loaded? That way you wouldn't have to worry about anything except making sure that 30% fits nicely into your text field. Think about it: How fast is someone willing to or capable of reading anyways. By the time he/she reads the 30% of stuff u loaded, some new text would have trickled in, and so on!

That being said, and if you insist on proceeding in the fashion you described earlier, perhaps you can try setting up a listener and onLoadProgress you do some checking to see if there is enough text for a scroll bar, and only then would u reveal it by hiding the movie clip on top of it.
So it would go something like this:


var listener:Object = new Object();
var loading_stream_obj:Object = new Object();//This would
//probably be your File or XML object or whatever can keep
//track of how much has been loaded
listener.onLoadProgress = function()
{

//calculate the number of lines or find out how much has been loaded
//if enough has loaded
//do something like: myMaskClip._visible = false;

}//end of listener
loading_stream_obj.addListener(listener);


I am not an expert myself, and I know what I just wrote might be confusing, but I am hoping that at least it might give you some ideas to work on. :D :)

Good luck