# Preloader to pass variable to loaded swf

**URL:** <https://forum.kirupa.com/t/preloader-to-pass-variable-to-loaded-swf/275979>\
**Category:** flash\
**Created:** [November 20, 2008, 10:01pm UTC](https://forum.kirupa.com/t/preloader-to-pass-variable-to-loaded-swf/275979 "2008-11-20T22:01:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![xenos](https://avatars.discourse-cdn.com/v4/letter/x/ea5d25/32.png) [@xenos](https://forum.kirupa.com/u/xenos)\
**Post date:** [November 20, 2008, 10:01pm UTC](https://forum.kirupa.com/t/preloader-to-pass-variable-to-loaded-swf/275979/1 "2008-11-20T22:01:31Z")

</div>

I’ve been reading up on LocalConnection, LoaderInfo, and SharedObject but can’t seem to get anything to work. There must be a simple way for a preloader to pass a variable to the swf it loads.

I’ve got a preloader swf that loads my main swf that gets it’s content from a xml file. I would like to pass the location of the xml file as a string with a flashvar to the preloader that then passes the location variable to the main swf. Here’s my code for the preloader:

```auto

var l:Loader = new Loader();
l.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loop);
l.contentLoaderInfo.addEventListener(Event.COMPLETE, done);
l.load(new URLRequest("visitor_map2.swf"));

function loop(e:ProgressEvent):void {
    var perc:Number = e.bytesLoaded / e.bytesTotal;
    percent.text = Math.ceil(perc*100).toString();
}
function done(e:Event):void {
    removeChildAt(0);
    percent = null;
    addChild(l);
}

```

Doesanyone know of a simple way for me to pass 1 variable form 1 swf to another? Thanks!
