The first thing that we added is the loadVariables statement. This loads the variables from the text.txt file. Now, when Flash opens the text file, it sees daTextBox=blablabla, so it sets the internal variable daTextBox to «blablabla». Note that we use the "this" operator, which refers to the current clip, to show Flash that we want the variables loaded into containerMC, not in the main timeline or in some other clip.
This single line asks Flash to load the text file into the movie. When the text is on a server, Flash has to make a connection to it and retrieve the data. This takes time. Now, it's useful to know when the text has finished loading. You might want to do something when the text is loaded, like play a "tada" sound, for example.
Hence, we introduce yet another clip event, data. The data clip event is fired immediately after a text file is loaded with loadVariables. So when the data clip event is fired, we know the file is loaded into Flash.
It's not enough, however, to know that the text file is loaded. You see, when Flash loads a text file into a movie, it must parse the file, and parsing takes time. So even though our text file is loaded, Flash might only fill the textbox one or two frames later.
So what is done is, at first, the needInit variable is set to false. When the textfile is loaded, the data clip event is fired, and the variable needInit is set to true. In our enterFrame clip event, this fires an if condition. This if checks whether or not the textbox's maxscroll property has been updated. If it has been updated, it should be bigger than 1, and that means is text is both loaded and parsed.
Right now, there's only a comment in there that says "Text is loaded!". Later, when the scrollbar is added, we'll fire an event when we know the textfile is loaded and parsed to change the height of our scrolbar. Confused? Maybe a diagram will help:

That wasn't too hard now, was it? It's time for some hardcore ActionScript.
| » Level Intermediate |
|
Added: 2001-07-17 Rating: 8 Votes: 176 |
| » Author |
| No details available. |
| » Download |
| Download the files used in this tutorial. |
| Download (34 kb) |
| » Forums |
| More help? Search our boards for quick answers! |
-
You must have javascript enabled in order to post comments.


Comments
There are no comments yet. Be the first to comment!