LoadVars Preloading Function

Thought I would share this with everyone. It is three small functions, made with Flash MX 2004 Pro, that will load variables into any designated movieclip, run a preloader clip, and remove it when all variables are present. Here’s the code:
[AS]
_global.loadPHP = function(url, clip, loadClip) {
// url: your variable processor
// clip: clip that will contain the variables
// loadClip: designated preloader movieclip
clip.onLoad = function() {
getVars = new LoadVars();
getVars.load(url);
addLoader(clip, loadClip);
};
clip.onEnterFrame = function() {
if (getVars.loaded) {
// if variables are present and fully loaded remove loader
//trace(“variables loaded”);
removeLoader(clip, loadClip);
}
};
};
_global.addLoader = function(clip, loadClip) {
// attach loadSqr clip
loadObj = {_x:5, _y:5};
clip.attachMovie(loadClip, loadClip, 1, loadObj);
};
_global.removeLoader = function(clip, loadClip) {
// remove loadSqr clip
clip[loadClip].removeMovieClip();
};
[/AS]

Cheers:beer:
CJ