Journey of a Software Developer
HTML | CSS | JavaScript | ASP.NET | PHP | C# | Java | VB.NET | MS SQL | MySQL | Flash
HTML | CSS | JavaScript | ASP.NET | PHP | C# | Java | VB.NET | MS SQL | MySQL | Flash
Dec 3rd
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!