Skip to main content
Known Participant
July 11, 2006
Answered

Loading text dynamically...

  • July 11, 2006
  • 7 replies
  • 861 views
This is driving me nuts. I'm trying to load an html text file into a dynamic text box labeled 'loadedInfo.' 'loadedInfo' is in a movieclip instance called 'text_field' - however I can't seem to get it to work or even pull up the error that I wrote into the action script (even though I have a similar script working on another site I did).

Here's my actionscript to pull that variable into the dynamic text box (it's in the main timeline):

myLV.load("resume.txt");

//Load Vars
var myLV:LoadVars = new LoadVars();
myLV.onLoad = function(success) {
if (success) {
text_field.loadedInfo.htmlText = myLV.info;
} else {
text_field.loadedInfo.text = "There has been an error loading the requested information. Please contact the webmaster and report your error.";
}
}

If you want to see the swf file it's here:
http://www.midnight007.com/pizza/layer_100resume.swf

And, if you want to see the fla file it's here:
http://www.midnight007.com/pizza/layer_100resume.fla
This topic has been closed for replies.
Correct answer Craig Grummitt
i'm sorry time for me to miss something - i didn't realise you'd posted a link to your fla already - i should have just looked at that!

Your text_field movie clip and therefore your loadedInfo text box does not exist on the stage at the point where you introduce your onLoad event handler. So if your onLoad handler is called before the timeline reaches frame 6 when your text_field movie clip appears, it won't do what you want it to do. Copy frame 6 of the loadedInfo layer and paste it in frame 1 and the text should appear okay.

7 replies

Craig Grummitt
Craig GrummittCorrect answer
Inspiring
July 12, 2006
i'm sorry time for me to miss something - i didn't realise you'd posted a link to your fla already - i should have just looked at that!

Your text_field movie clip and therefore your loadedInfo text box does not exist on the stage at the point where you introduce your onLoad event handler. So if your onLoad handler is called before the timeline reaches frame 6 when your text_field movie clip appears, it won't do what you want it to do. Copy frame 6 of the loadedInfo layer and paste it in frame 1 and the text should appear okay.
swim4itAuthor
Known Participant
July 12, 2006
Thanks! Duh! I knew it was something simple like that...thanks for being another pair of eyes!
Craig Grummitt
Inspiring
July 12, 2006
don't worry i think kglad just missed that that problem had already been picked up.

i still think your animation's the problem - do you realise that device fonts can only be displayed upright and horizontally? if you embed the fonts, or remove any transitions on the movieclip you've implemented, you should find that the text appears okay.
swim4itAuthor
Known Participant
July 12, 2006
Alright - I embedded the font AND took away the animation (it appears when everything else does) - still not even coming up with the error that it should in the loadVars function. Any more ideas?

The newer swf and fla have been uploaded and are in the same url that they were before.
kglad
Community Expert
Community Expert
July 12, 2006
that code can't work. you're using myLV before it's instantiated. try:

swim4itAuthor
Known Participant
July 12, 2006
quote:

Originally posted by: kglad
that code can't work. you're using myLV before it's instantiated. try:



This is the code I have now - I changed it and re-uploaded it this morning - isn't this what you meant?:



//Load Vars
var myLV:LoadVars = new LoadVars();

myLV.onLoad = function(success) {
if (success) {
text_field.loadedInfo.htmlText = myLV.info;
} else {
text_field.loadedInfo.text = "There has been an error loading the requested information. Please contact the webmaster and report your error.";
}
}
//Load Vars
myLV.load("resume.txt");

Craig Grummitt
Inspiring
July 12, 2006
what are you animating? the movieclip or the textfield inside the movieclip? see what happens if you do not animate it. are you embedding characters?
swim4itAuthor
Known Participant
July 12, 2006
quote:

Originally posted by: Craig Grummitt
what are you animating? the movieclip or the textfield inside the movieclip? see what happens if you do not animate it. are you embedding characters?


I'm animating the movie clip titled "text_field" that holds the dynamic text box inside of it. Same thing happens if I do not animate it. The font right now is set to _sans - so it should use any font that is on the users computer. The font doesn't seem to be the issue anyway because everything works fine UNTIL I put the dynamic text box into a movie clip.

swim4itAuthor
Known Participant
July 11, 2006
Yes - I originally had the myLV.load("resume.txt"I); line below everything else. I moved it back there and it still isn't working. (new files have been uploaded) I've found that everything works including the text being pulled dynamically UNTIL I put it into the movieclip text_field and animate it. If the dynamic text field is on the original time line it works. I changed the paths in the script - but it still isn't working - any ideas why that changed it all? Can you not put a dynamic text field inside a movieclip and animate it?
Participant
July 11, 2006
I think the issue has to do with the paths to the dynamic text field.
Craig Grummitt
Inspiring
July 11, 2006
You've got a movieclip called text_field? That's gotta be confusing...

You have to define your LoadVars variable before you try and use it...
Swap your first three lines around like so:

//Load Vars
var myLV:LoadVars = new LoadVars();
myLV.load("resume.txt");