HTML | CSS | JavaScript | ASP.NET | PHP | C# | Java | VB.NET | MS SQL | MySQL | Flash
Flash CS3, UIScrollBar, scroll arrows not displaying on dynamic text
I am currently working on a Flash CS project and I recently came across an issue with using the UIScrollBar component.. The issue was quite intermittent; but after attaching the scroll bar component to dynamic the text box I was expecting to see bars and the arrows when the contents within the text box were larger than the constraints defined for the text box. After running the project both within the browser and in the SWF player, I noticed that on some occasions the scrolling was active and on some, inactive.
After a few hours of research, I still couldn’t find a resolution to this issue. Then, I turned to the Flash CS3 documentation and after some careful reading of the UIScrollBar component documentation, I found the answer. The documentation mentioned that if you are dynamically loading text from an external source from ActionScript and then assigning that text to the dynamic text box, you must call the update() method on the scroll bar component to alert it that the contents have changed. So, if you have an instance of a dynamic text box on the stage called mytext_txt, and you attach a UIScrollBar component to the box by dragging the component on top of it. You then must assign a instance name to the scroll bar component so that you can reference it within ActionScript. Let’s say I name it mytext_scroll. Here is what the ActionScript 3 would look like:
1: import flash.display.*;
2: import flash.events.*;
3:
4: var textLoader:URLLoader = new URLLoader();
5: var simpleReq:URLRequest = new URLRequest("mytext.txt");
6:
7: textLoader.load(simpleReq);
8: textLoader.addEventListener(Event.COMPLETE, textComplete);
9:
10: function textComplete(event:Event):void {
11: mytext_txt.text = textLoader.data;
12: mytext_scroll.update();
13: }
Notice the update() on line 12. This seem to do the trick for me. Hopefully, I was able to help someone figure this issue out. Until next time…
Happy Coding!
| Print article | This entry was posted by admin on December 3, 2007 at 10:01 pm, and is filed under Flash. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |
about 2 years ago
Hi!, Do you know how to just remove it when it is disabled. Thanks.
about 2 years ago
I’m not sure if I understand your question that well. When the UIScrollBar is disabled, it shouldn’t display at all. That’s the behavior that I have been seeing. Also, if the content within the dynamic textbox is smaller than the actual size of the textbox then the scrollbar is usually not shown. This is as much as I can say right now. Thanks for your comment.
about 2 years ago
Fantastic!! THanks
about 2 years ago
The UIScrollBar component shows up even when there’s very little text, however the scrollbar is disabled so you just see an ugly grey bar that doesn’t do anything. If the component is disabled you know you don’t need it, in which case I set the component to .visible=false, see code below:
myScrollBar.update();
if(quest_mc.mySB.enabled==false)
{
myScrollBar.visible=false;
}
about 2 years ago
Sorry, that code above had an error in it. It should be…
myScrollBar.update();
if(myScrollBar.enabled==false)
{
myScrollBar.visible=false;
}
about 2 years ago
Ok…Cool. Thanks for sharing that.
about 1 year ago
Hey there,
I was having the same problem you described, and then I found this. It’s saved me some time. Thanks very much!!
about 1 year ago
Thanks for the simple explanation and fix. This solved my problem!
about 1 year ago
@Vikram
@Beckham
Happy to help. I’ve been saved many time by others who blogged about the same issue I was having. It feels great to return the favor.
about 1 year ago
Do you know how to remove Up and Down button from a UIScrollBar in AS 2.0? So I want to use only the Track and Thumbscroller from a UIScrollbar. Cheers.
about 1 year ago
Thanks for the post! Really helpful!!
about 1 year ago
Thanks so much
about 1 year ago
Brilliant – thanks a lot.
about 1 year ago
Wow, I never thought this small tip would help so many. I guess the Adobe people need to be more clear about these types of situations.
about 11 months ago
Thanks for this tip, It just solved my problem.
about 10 months ago
your amazing and I love you! Thank you for posting this. I looked forever!
about 10 months ago
Thanks,
Had the same problem but your tip worked.
Yes, Adobe would benefit from explaining these kind of situations in an understandable format
about 10 months ago
You are welcome Josh.
about 8 months ago
Could you help me, to solve the same problem in AS2? I’m trying to ‘translate’ your code to as2, but everytime sth wont work :/. I’m just begginer and it would be very helpfull for me.
Cheers.
Mic
about 3 months ago
for people seeking this.
afther update the scrollbar is going to the max.
so the the last line of text is shown.
myScrollBar.update();
myScrollBar.scrollPosition=myScrollBar.maxScrollPosition;
greets
jud
about 2 months ago
thanks a lot! My problem has finished, good job!