![]()
Hi
Can anyone tell me if there is something wrong with my code?
I followed a tutorial word for word on Lynda.com to create a dynamic text field and scroll some text in it. The tutorial on Lynda.com works ‘fine and dandy’ but mine doesn’t.
I have attached my code and accompanying files.
Basically I load some text and apply a stylesheet.
I then load this into the dynamic textfield (external_txt) which lives within text_mc.
I then perform some calculations and attempt to scroll.
I am certain the calculations are correct. It is just that when the textfield doesnt resize the values end up wrong and the results is th text scrolls in the wrong direction.
There is a line of code that says:
text_mc.external_txt.autoSize = TextFieldAutoSize.LEFT;
However, when I trace the height of text_mc (within the textLoaded function) the height has shrunk rather than autosized to a bigger value.
The result of this is that my text scrolls in the wrong direction when I use the drggable scroller (scroller_mc).
Can anyone advise?
Many Thanks
Ok, the problem was this.
The line:
text_mc.external_txt.htmlText = textLoader.data;
needed to be in the textLoaded function instead of the cssLoaded function.
Moving this line of code fixed the problem. Although I have to admit that I’m not sure EXACTLY why this is. If anyone can figure out why this is the case I would be very grateful.
I’ve uploaded a new .fla called textTest.fla. You can get the css file and txt file out of the zip file in my original post.
Does anybody know exactly why this works and my first fla didn’t? ![]()
Cheers
:-)
- 24 April 2008 12:10 PM
-
Ok…After sticking several trace statements in the code I figured out the reason is to do with the fact that the cssLoaded() handler had not finishing processing its code and the textLoaded() handler had gone ahead and calculated the minScroll and maxScroll values using the initial/current value of text_mc.height (which is about 19.9000000 - which I assume is the height of 1 line of text). [It’s approx 20 and this I think is to do with “twips” but that’s another topic!]
BUT text_mc.height had not been updated as the following line of code had not executed:
text_mc.external_txt.htmlText = textLoader.data;
By the time it had executed and cssLoaded() had finished its work it was too late.
By moving this line of code into the textLoaded() handler everything works because autoSize kicks in and thus text_mc.height gets updated appropriately.
I thank you and good night
- 25 April 2008 06:24 AM
-
- Log in or join for free to make a comment.


