I wanna create some sort of actionscripted typewriter which loads its content from an external file, but i can’t seem to get the code to work properly!
This is what i got till now:
2 layers:
- one with a textfield called ‘textbox’
- one with the actions
A textfile which contains: waarde=Wannaloadtextfromanexternaltextfile!
4 frames, in the first frame i load the textfile this way:
[AS]q = 1;
loadText = new loadVars();
loadText.load(“data.txt”,this);
loadText.onLoad = function(success) {
if (success) {
trace(this.waarde);
text = this.waarde;
} else {
trace(“Error”);
}
};[/AS]
In the second frame is the typewriter code, pretty straigtforward:
[AS]if (q < text.length) {
textbox = text.substring(0, q);
q++
} else {
textbox = text;
gotoAndStop(4);
}[/AS]
And the third frame just loops back to the second for the typewriter effect.
Fourth frame is empty
The problem is that when i assign the value of “text” in the first frame this way : <-- text = “Wannaloadtextfromanexternaltextfile!”; --> (witout the comment tags ofcourse) the typewriter works fine but when i load the var from the textfile nothing happens, the trace works fine and displays the contents of the var but the typewriter displays nothing.
the weird this is that when i add this after all the code in frame 1 it works fine: text = “azerty”;
But when i add this it doesn’t: text = “a”;
So when i overwrite the var with the azerty value suddenly it contains the correct value in the next frame, when i assign only one character to it the script doesn’t work anymore. Some weird **** here :o
I included the code for you guys to look at!
I hope someone can help me out here.