Loading text into a swf into anonther swf

Hiya!

Hope you can help me! This is driving me nuts! I have a swf with a dynamic text box (which is inside a movieclip) which loads text from a .txt file. This swf is then loaded into a blank mc (main) in another swf.

The text appears if I view the child, but in the parent, the child swf appears but not the text. I have tried nearly every combintation of actionscript to get it to load!! Please help!! My code is as follows…

In the parent swf…

_root.main.loadMovie("welcome.swf")

In the child swf…

loadVariables("axiostext.txt", "box");

The text has a variable name of welcometext. Please help!!

Thanks :o)

why don’t you load the text through the parent, and send it to the child after its a variable:


//load stuff
_root.child.welcometext = welcometext

If that makes sense.

Thats not working either. The text loads fine whether I load it into the parent or the child, as I did a test to make sure. It just doesnt seem to want to send it to the child swfs textbox once you play the main movie. Im nearly tearing my hair out here!! Please someone help!!!

:crying: :crying:

does the text box refer to a variable on the roo(_root.variable). because if its a child movie clip (even if it was loaded), the _root.variable refers to the timeline of the parent, not the child.

No, I have changed my code where it says _root and replaced it with this. or _parent. as from what Ive read on these problems, that is better coding.

I also found tutorials on using LoadVars which works fine in a swf, it also works fine if you load the swf into another swf. But when I load it into a blank movieclip in a swf the text disapears again.

But even the easy way I was doing it before seems to work, until I try to target the text box in the blank mc.

Any ideas?

i really appreciate your help!!!

Cheers, Jen :}

hmmmm… I think I might know, because loading a variable is an asycronous action you may be trying to send the variable to the child before it exists. So try this:


loader = new LoadVars(); //create the loadvars object
loader.load("text_file_here.txt"); //this can be any type of file that returns text (IE: PHP, ASP etc)
loader.onLoad = function(success) {
	if(!success) { //tests the success variable to ensure it loaded
		this.welcometext = "Error"; //makes the variable an error if it didn't load the variable
	}
	_root.child.welcometext = this.welcometext; //send the variable to the child
}

I hope that works for you.

jerez_z :hugegrin: You are an absolute :angel:

Thank you thank you thank you thank you thank you!!!

I may be back with more questions before I finish this project! (But hopefully not!!!)

Thanks again! Jen :}

glad to be of help :smiley: