loadVariables using variable instead of url?

Just wondering if it was possible to set the url in a variable name in the event that you wanted different files loaded into the same text field, like:

url=‘myUrl.txt’;
loadVariables(myUrl,0);

Did a search for this information but came up with nothing.

So you’re saying that you want the variables to load from a different file using the dynamic textboxes URL link and not actionscript? Well, I think that can be done using asfunction. Do a search on that, type in loadVariablesNum using asfunction. :slight_smile:

What I want is to be able to load using LoadVariables, but instead of providing the exact url I want it to check a variable for the url, is that possible?

Oh ok. So what you want to do is: Using ActionScript: Search for a Variable in the movie: That has the name of the URL: Take that name: And use that name to load. Here’s what you wanna do:[list=1]
[]Make a variable called URL. Inside it, type in the url that links to the text file.
[
]Make another variable called display. Inside it will be what is loaded.
[]Make a text document and put: display=Hello.
[
]For the actionscript, put in first frame:

loadVariablesNum(URL, 0);

[/list]
This code makes it get what the URL is from a variable. Then using that URL, it goes to the URL, reads what will be displayed in the display variable, and shows that text in flash!

  • Hope I helped. :egg:

Actually, I think he wants to set up an input box so one can type in the url, then have LoadVariables pull in a text file and toss it into a dynamic text box. At least I think, I’m not sure. If so, yes you can, but your first post’s code is wrong:


url='myUrl.txt';
loadVariables(myUrl,0);
//should be
url='myUrl.txt';
loadVariables(url, 0);

But if that’s what you’re doing, I would do this:


url = 'myUrl.txt';
lv = new LoadVars();
lv.onLoad = function (success){
if (success){
textboxname.text = this.display;
}
}
lv.load(url);

Then, as Sharif said, make a text file that has this in it:


display = all the stuff you want to have appear in the textbox

Awesome, loadVars fixed my problems - Thanks.

**** it thunder! This means war!

  • BTW, My code did work fine, but I didn’t understand that he wanted me to type something in.