# Dynamically Loading SWF into a Particular Frame

**URL:** <https://forum.kirupa.com/t/dynamically-loading-swf-into-a-particular-frame/277443>\
**Category:** flash\
**Created:** [December 12, 2008, 2:22am UTC](https://forum.kirupa.com/t/dynamically-loading-swf-into-a-particular-frame/277443 "2008-12-12T02:22:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![meekos](https://avatars.discourse-cdn.com/v4/letter/m/e19b73/32.png) [@meekos](https://forum.kirupa.com/u/meekos)\
**Post date:** [December 12, 2008, 2:22am UTC](https://forum.kirupa.com/t/dynamically-loading-swf-into-a-particular-frame/277443/1 "2008-12-12T02:22:02Z")

</div>

Hello,

I am a Flash beginner. I am creating a web site using Flash CS4 and AS3. I have been able to create the pages by using frame labels. Every was going fine until tried dynamically loading a SWF file (previously created). The problem is I’ve placed the code for the SWF load on the frame label that I want it to load into which works fine. However when I click on any to the other pages the SWF file is displayed also. Can anyone tell me how to stop this from happening? Is their an event listener for leaving a frame? I am attaching my code in the hopes that someone know where I am going wrong.

```auto
function loadProducts()
{
var mLoader:Loader = new Loader();

var mRequest:URLRequest = new URLRequest("productsv1.swf");
mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
mLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler);
mLoader.load(mRequest);
}

function onCompleteHandler(loadEvent:Event)
{
    var ploader:MovieClip = new prodLoader();
    loadEvent.currentTarget.content.x = 0;
    loadEvent.currentTarget.content.y = 0;
    ploader.addChild(loadEvent.currentTarget.content);
    ploader.x = 0;
    ploader.y = 160;
    ploader.width = 800;
    ploader.height = 400;
    addChild(ploader);
}

function onProgressHandler(mProgress:ProgressEvent)
{
var percent:Number = mProgress.bytesLoaded/mProgress.bytesTotal;

trace(percent);
}

loadProducts();

```
