# Loading swfs into a container

**URL:** https://forum.kirupa.com/t/loading-swfs-into-a-container/262081
**Category:** flash
**Created:** [June 3, 2008, 6:02am UTC](https://forum.kirupa.com/t/loading-swfs-into-a-container/262081 "2008-06-03T06:02:31Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![mariuskatz](https://avatars.discourse-cdn.com/v4/letter/m/9f8e36/32.png) [@mariuskatz](https://forum.kirupa.com/u/mariuskatz)
#### Post date: [June 3, 2008, 6:02am UTC](https://forum.kirupa.com/t/loading-swfs-into-a-container/262081/1 "2008-06-03T06:02:31Z")

</div>

I am trying to load various swf into one container (instancename:holder).

In As2 i used to declare a variable, change its properties via buttons and load the swf using the MovieLoaderClass into the holder clip.

what is cool about this is the fact that when you load a different movie or a website category, firstly the exisiting movie exits and then the new is loaded which leads to smooth transitions.

i used the MovieLoaderClass heavily which doesn’t work in AS3.

loading a swf in AS3 is straight forward but cannot seem to get my head around loading swf via a variable

---

<div class="post-metadata">

### Author: ![Pier25](https://avatars.discourse-cdn.com/v4/letter/p/4af34b/32.png) [@Pier25](https://forum.kirupa.com/u/Pier25)
#### Post date: [June 3, 2008, 8:50am UTC](https://forum.kirupa.com/t/loading-swfs-into-a-container/262081/2 "2008-06-03T08:50:25Z")

</div>

Here’s a function I did this weekend to load an external swf. If you want to load another one simply call the function again with another url.

```auto

		public function cargar_archivo(url:String,scope:Object):void{
			var loader:Loader = new Loader();
			var archivo:URLRequest = new URLRequest(url);
			
			loader.load(archivo);
			loader.contentLoaderInfo.addEventListener(Event.INIT, cargado);
			
			function cargado(evento:Event):void{
				setTimeout(init_archivo,2000,evento.target.content);
				evento.target.content.alpha = 0;
				evento.target.content.stop();
				scope.addChild(evento.target.content);				
			}

		}

```

---

<div class="post-metadata">

### Author: ![Alex\_Lexcuk](https://avatars.discourse-cdn.com/v4/letter/a/919ad9/32.png) [@Alex\_Lexcuk](https://forum.kirupa.com/u/Alex_Lexcuk)
#### Post date: [June 3, 2008, 7:30pm UTC](https://forum.kirupa.com/t/loading-swfs-into-a-container/262081/3 "2008-06-03T19:30:18Z")

</div>

[http://kind-armadillo.pochta.ru/FlaAC3/curve.swf](http://kind-armadillo.pochta.ru/FlaAC3/curve.swf)  
[http://kind-armadillo.pochta.ru/FlaAC3/loadSWF.swf](http://kind-armadillo.pochta.ru/FlaAC3/loadSWF.swf)  
[http://kind-armadillo.pochta.ru/FlaAC3/loadSWF.rar](http://kind-armadillo.pochta.ru/FlaAC3/loadSWF.rar)

[http://kind-armadillo.pochta.ru/fla/osc.swf](http://kind-armadillo.pochta.ru/fla/osc.swf)  
[http://kind-armadillo.pochta.ru/FlaAC3/RotateSWF.swf](http://kind-armadillo.pochta.ru/FlaAC3/RotateSWF.swf)  
[http://kind-armadillo.pochta.ru/FlaAC3/RotateSWF.rar](http://kind-armadillo.pochta.ru/FlaAC3/RotateSWF.rar)
