# Help needed loading swf from within another swf

**URL:** https://forum.kirupa.com/t/help-needed-loading-swf-from-within-another-swf/280072
**Category:** Uncategorized
**Created:** [January 22, 2009, 10:33am UTC](https://forum.kirupa.com/t/help-needed-loading-swf-from-within-another-swf/280072 "2009-01-22T10:33:24Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![kid\_kime](https://avatars.discourse-cdn.com/v4/letter/k/8e8cbc/32.png) [@kid\_kime](https://forum.kirupa.com/u/kid_kime)
#### Post date: [January 22, 2009, 10:33am UTC](https://forum.kirupa.com/t/help-needed-loading-swf-from-within-another-swf/280072/1 "2009-01-22T10:33:24Z")

</div>

[SIZE=1]Hello,[/SIZE]

[SIZE=1]This is my first post on here, and i’m really stuck with what i am trying to do![/SIZE]

[SIZE=1]Im new to AS3 but so far have coped well with the site i am building - i’m not great on refering to things in technical terms, so I appologise in advance![/SIZE]

[SIZE=1]Ok, here is how my site is laid out:[/SIZE]

[SIZE=1] **‘template.swf’** is basically just that - it has a navigation bar which loads external swfs (2 per button, a left hand swf and a right hand swf)[/SIZE]

[SIZE=1] **‘main\_aboutmonkey.swf’** - this is the swf which is loaded into the right hand side of the template, when the home button is pressed[/SIZE]

[SIZE=1] **‘main\_appreciation.swf’** - this will be the second page I need to load into the template, on the right hand side[/SIZE]

[SIZE=1]The problem i’m having is loading the **main\_appreciation.swf** from _WITHIN_ the **main\_aboutmonkey.swf** , rather than from the navigation on **template.swf** [/SIZE]

[SIZE=1]This is the code I am using:[/SIZE]

[SIZE=1]Frame 1 on **template.swf** :[/SIZE]

```auto
var swfLoaderMain:Loader = new Loader();
 
swfLoaderMain.x = 291;   
swfLoaderMain.y = 77;
 
var swfLoaderLeft:Loader = new Loader();
swfLoaderLeft.x = 18;   
swfLoaderLeft.y = 111;
 
 
var swfRequestMainAboutMonkey:URLRequest = new URLRequest("swf/main_aboutmonkey.swf");
var swfRequestLeftAboutMonkey:URLRequest = new URLRequest("swf/left_aboutmonkey.swf");

```

[SIZE=1]On the Button which loads **main\_aboutmonkey.swf** on the navigation of\*\* template.swf\*\*:[/SIZE]

```auto
nav_aboutmonkey.addEventListener(MouseEvent.ROLL_OVER, nav_aboutmonkeyOver);
 
nav_aboutmonkey.addEventListener(MouseEvent.ROLL_OUT, nav_aboutmonkeyOut);
nav_aboutmonkey.addEventListener(MouseEvent.CLICK, nav_aboutmonkeyClick);
function nav_aboutmonkeyOver (event:MouseEvent):void{
nav_aboutmonkey.gotoAndPlay("Over");
}
function nav_aboutmonkeyOut (event:MouseEvent):void{
nav_aboutmonkey.gotoAndPlay("Out");
}
function nav_aboutmonkeyClick (e:MouseEvent):void
{
swfLoaderMain.load(swfRequestMainAboutMonkey);
swfLoaderLeft.load(swfRequestLeftAboutMonkey);
 
}

```

[SIZE=1]This code all works fine, and I have various buttons on the navigation and I am able to load different swf files from the different buttons.[/SIZE]

[SIZE=1]So, I have a button within \*\*main\_aboutmonkey.swf \*\*which should load to a seperate movie \*\*(main\_appreciation.swf) - \*\*the problem is, that it loads **main\_appreciation.swf** on top of **main\_aboutmonkey.swf,** rather than removing **main\_aboutmonkey.swf** first - here is the code which is on frame 1 on a movie clip (appsoc), in another movie clip (full movie) on the stage, of **main\_appreciation.swf** [/SIZE]

```auto
var swfLoaderMain:Loader = new Loader();
swfLoaderMain.x = 291;   
swfLoaderMain.y = 77;
 
var swfLoaderLeft:Loader = new Loader();
swfLoaderLeft.x = 18;   
swfLoaderLeft.y = 111;
 
 
appsoc_invisibut.buttonMode = true;
appsoc_invisibut.addEventListener(MouseEvent.ROLL_OVER, appsoc_invisibutOver);
appsoc_invisibut.addEventListener(MouseEvent.ROLL_OUT, appsoc_invisibutOut);
appsoc_invisibut.addEventListener(MouseEvent.CLICK, appsoc_invisibutClick);
 
function appsoc_invisibutOver (event:MouseEvent):void{
appsoc_monkey.gotoAndPlay("Over");
}
function appsoc_invisibutOut (event:MouseEvent):void{
appsoc_monkey.gotoAndPlay("Out");
}
function appsoc_invisibutClick (e:MouseEvent):void
{
swfLoaderMain.load(swfRequestMainAppreciationSociety);
swfLoaderLeft.load(swfRequestLeftHome);
MovieClip(parent.parent.parent.parent).addChild(swfLoaderMain); 
MovieClip(parent.parent.parent.parent).addChild(swfLoaderLeft);
 

```

[SIZE=1]Sorry this is so long winded, I just wanted to give as much information as possible,[/SIZE]

[SIZE=1]Any help would be much appreciated,[/SIZE]  
[SIZE=1]Thanks,[/SIZE]  
[SIZE=1]John[/SIZE]
