¿ loadVariables or loadvars?

which is which? :hangover: im just starting out with this stuff and found myself confuse… which one should i use? …or which one is preferrable to use…loadVariables or loadVars?

…and please “educate” me further for as i have said, im just starting out… thanx.


I am in no position to educate somebody else… So, I’ll just say what I think… :wink:

As long as you use FMX and you have no reason to export your movie to F5, use LoadVars() object… Don’t ask… Just use it and I am sure you will thank me later… :beam:

thanx a lot cyan… i understand… but for sure, you have the position to tell me some links and/or tutorial with regards to this one… :wink:

Well… Don’t really know about that…

Let me give you an example just in case that makes you feel better… :wink:

If you use loadVariables() function, you have to code yourself how to check if the data is fully loaded, and sometimes it is really painful thing… But you can use onLoad handler if you use LoadVars() object and it is built-in function…

Other than that, go to Macromedia’s website and check out the FMX release note… I think I have seen something about the LoadVars() from there… :wink:

Here is a simple example of how to use LoadVars ()

[AS]user_vars = new LoadVars();

user_vars.username = _level0.login_username.text;
user_vars.pass = _level0.login_pass.text;

user_vars.onLoad = loginLoadHandler;
user_vars.sendAndLoad(“login.php?random=”+random(9999999), user_vars, “POST”);[/AS]

That will send two variables called login_username and login_password to a login php script. Once the script is done processing you would have something like this to handle the outcome.

[AS]loginLoadHandler = function(success) {
if (success) {
//Do whatever you want to do

Howdy, Immulsifier…

random() function could give you two same numbers no matter how big the argument is… and it is deprecated in F5… You might want to use getTimer() function instead…
And it is always a good idea to specify the domain name with the PHP file you are calling…
Just my 2 cents… :wink:

user_vars.sendAndLoad("login.php?random="+random(9999999), user_vars, "POST");

user_vars.sendAndLoad("http://www.domain.com/login.php?uniqueID=" + getTimer(), user_vars, "POST");

it is always a good idea to specify the domain name with the PHP

Why’s that? Makes no difference whatsoever…

And LoadVariables is very easy to use if you just load a textfile, all you have to do to check the load status is add a variable to the end which you check on, if this last one is loaded, the rest is to.
Main difference between the 2 is that loadVars is an object with it’s own properties/methods, and only available since Flash MX, loadVariables is backwards compatible.
Purpose of both is the same, so try both, old versions is easier to start with, loadVars will be tomorrows standard.

Well… I was just saying that off of my experiences…

When I upload the project online, sometimes I had to specify the whole domain name as an absolute path to get the movie working on Netscape… So, I started doing it that way…
Also if I test the movie under the localhost, I just set the domain variable to localhost so that I don’t have to publish the HTML file and test it in the browser…

As I was saying, I was just throwing my 2 cents… :wink:

btw, it is really usefull to use the ful path if you have a database online with the (php) scripts, coz then you can test live content right out of flash…
i just don’t like the idea of someone getting the swf (browser cache), and being able to access the content from their desktop…

Well… I do that because that is convenient for me when authoring… Like I was saying, I don’t have to go back and forth to test things…

What I am saying will be something like this…

domain = "http://localhost/";
//domain = "http://www.mydomain.com/";
myLVs.sendAndLoad(domain + "myfile.php?uniqueID=" + getTimer(), myLVs, "POST");

I just comment out the appropriate domain name when testing and change it when I upload it onto the server… This worked for me just fine… :wink:

As for somebody stealing the SWF file… You can at least check the _url property and see if it starts with HTTP and decide from there… That could be the minimal thing you can do to protect what you have… :wink:

Here’s a nice one to use:

String.prototype.noCache = function ()
        if (_root._URL.substr(0, 5).toLowerCase() != "file:")
            if (this.indexOf("?") == -1)
                (this = this + ("?noCache=" + new Date().getTime()));
                return(this = this + ("?noCache=" + new Date().getTime()));
                (this = this + ("&noCache=" + new Date().getTime()));
                return(this = this + ("&noCache=" + new Date().getTime()));
            } // end if

use as loadVars (myFile.php.noCache());
(just found that, not tested yet…)

wow! im starting learning… and this is fun! …though i haven’t digest all what you have discussed (uha uhaaa… i can’t still take in much of solid foods :)) …anyhu, you gave some good milk though… thanks guys… im learning to walk now… :slight_smile:

Yes, eyezberg…

I think I have seen that prototype a while ago… That’s basically what I am talking about… :wink:

You can also check out the new tutorial on Kirupa.com, “AS and PHP made Easy”. It cover the use of LoadVars type variable.