# RANDOM! SWF loading multiple times? (when I only want it to load once)

**URL:** <https://forum.kirupa.com/t/random-swf-loading-multiple-times-when-i-only-want-it-to-load-once/298524>\
**Category:** Uncategorized\
**Created:** [October 20, 2009, 2:46pm UTC](https://forum.kirupa.com/t/random-swf-loading-multiple-times-when-i-only-want-it-to-load-once/298524 "2009-10-20T14:46:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dawn\_99](https://avatars.discourse-cdn.com/v4/letter/d/e8c25b/32.png) [@dawn\_99](https://forum.kirupa.com/u/dawn_99)\
**Post date:** [October 20, 2009, 2:46pm UTC](https://forum.kirupa.com/t/random-swf-loading-multiple-times-when-i-only-want-it-to-load-once/298524/1 "2009-10-20T14:46:54Z")

</div>

when I click a button it loads an SWF, then when I click another button it loads another SWF into the same loader. However it appears to be loading multiple SWF’s in conjuction with the amount of times I clicked a button. So say if I clicked a button 3 times it would load 4 of the same SWF’s on the forth time and load them at the same time.

[AS]var loader:Loader = new Loader();  
stage.addChild(loader);

var buttonArray:Array = [corporateIdentityMini\_mc, printMediaMini\_mc, publicationMini\_mc, digitalMediaMini\_mc, typographyMini\_mc, illustrationMini\_mc, photographyMini\_mc, pixelArtMini\_mc]; //instance names of your buttons  
var swfArray:Array = [“stars.swf”, “printMedia.swf”, “photography.swf”, “film.swf”, “video.swf”, “light.swf”, “corpID.swf”, “type.swf”];

//add the same event listener to all the buttons:  
for(var i:int = 0; i \< buttonArray.length; i++) {  
buttonArray\*.addEventListener(MouseEvent.CLICK, clickHandler);  
}

function clickHandler(event:MouseEvent):void {  
var clickedIndex:int = buttonArray.indexOf(event.currentTarget);  
loader.load(new URLRequest(swfArray[clickedIndex]));

}[/AS]
