# AS3 external loading plus preloader question (duplicate error)

**URL:** https://forum.kirupa.com/t/as3-external-loading-plus-preloader-question-duplicate-error/267162
**Category:** flash
**Created:** [July 29, 2008, 10:25am UTC](https://forum.kirupa.com/t/as3-external-loading-plus-preloader-question-duplicate-error/267162 "2008-07-29T10:25:17Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![RussianBeer](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/russianbeer/32/152_2.png) [@RussianBeer](https://forum.kirupa.com/u/RussianBeer)
#### Post date: [July 29, 2008, 10:25am UTC](https://forum.kirupa.com/t/as3-external-loading-plus-preloader-question-duplicate-error/267162/1 "2008-07-29T10:25:17Z")

</div>

First of all: Hi  
 ![](http://www.oman3d.com/forum/images/smilies/2.gif)  
I’ve been messing around in AS3 and I have the following problem; Im trying to have a button load an image and use a pre-loader. It all works fine until I try to get another button going (my\_btn2). Then I get a duplicate error.

Im terrible at AS3, can someone take a look.

```auto

import fl.controls.ProgressBar;

var myLoader:Loader = new Loader();

var my_pb:ProgressBar = new ProgressBar();
my_pb.source = myLoader.contentLoaderInfo;
my_pb.x = 100;
my_pb.y = 200;

my_btn.addEventListener(MouseEvent.CLICK, startLoading);
function startLoading(e:MouseEvent):void{
myLoader.load(new URLRequest("&#19987;&#21334;&#24215;.swf"));
addChild(my_pb);
removeChild(my_btn);
my_btn=null;
}

my_btn2.addEventListener(MouseEvent.CLICK, startLoading);
function startLoading(e:MouseEvent):void{
myLoader.load(new URLRequest("&#19987;&#21334;&#24215;.swf"));
addChild(my_pb);
removeChild(my_btn2);
my_btn2=null;
}

myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, finishLoading);
function finishLoading(e:Event):void{
addChild(myLoader);
removeChild(my_pb);
my_pb = null;
}

```
