# LoadVars Preloading Function

**URL:** <https://forum.kirupa.com/t/loadvars-preloading-function/98566>\
**Category:** Uncategorized\
**Created:** [January 8, 2004, 4:59pm UTC](https://forum.kirupa.com/t/loadvars-preloading-function/98566 "2004-01-08T16:59:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![onData](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/ondata/32/395_2.png) [@onData](https://forum.kirupa.com/u/onData)\
**Post date:** [January 8, 2004, 4:59pm UTC](https://forum.kirupa.com/t/loadvars-preloading-function/98566/1 "2004-01-08T16:59:37Z")

</div>

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
