# How to Preload External SWF

**URL:** <https://forum.kirupa.com/t/how-to-preload-external-swf/306888>\
**Category:** flash\
**Created:** [March 24, 2010, 1:21am UTC](https://forum.kirupa.com/t/how-to-preload-external-swf/306888 "2010-03-24T01:21:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pherank](https://avatars.discourse-cdn.com/v4/letter/p/4af34b/32.png) [@Pherank](https://forum.kirupa.com/u/Pherank)\
**Post date:** [March 24, 2010, 1:21am UTC](https://forum.kirupa.com/t/how-to-preload-external-swf/306888/1 "2010-03-24T01:21:20Z")

</div>

Does anyone know of a good way to preload external movies in advance?  
They only way I’ve figured out how to preload external file is like this:

First create separate loader objects to load each of the movies. Do this in a function that is called before the one below. You can’t use the same loader object to load all of the movies since the each load will destroy the one that preceeded it.

```auto

//Start preloading of external movies
preloaderOne.load(new URLRequest("One.swf"));
preloaderTwo.load(new URLRequest("Two.swf"));
preloaderThree.load(new URLRequest("Three.swf"));
preloaderFour.load(new URLRequest("Four.swf"));

```

Later, when you need to load the files into your “real” loader, you can use a switch statement or whatever to determine the appropriate movie for that action. Since the movies were loaded into memory earlier, they are readily available (even though they weren’t added to the display list). At least this seems to work when run from a web server.

```auto

public function showExternalMovie(file:String):void {
var externalItem:String = file.toLowerCase();
switch (externalItem) {
case "one" :
    externalLoader.load(new URLRequest("One.swf"));
    externalHolder.addChild(externalLoader);
    break;
case "two" :
    externalLoader.load(new URLRequest("Two.swf"));
    externalHolder.addChild(externalLoader);
    break;
case "three" :
    externalLoader.load(new URLRequest("Three.swf"));
    externalHolder.addChild(externalLoader);
    break;
case "four" :
    externalLoader.load(new URLRequest("Four.swf"));
    externalHolder.addChild(externalLoader);
    break;
    }
}

```

Comments?
