# Using arrays to load mc's from library

**URL:** https://forum.kirupa.com/t/using-arrays-to-load-mcs-from-library/301877
**Category:** flash
**Created:** [December 17, 2009, 4:54am UTC](https://forum.kirupa.com/t/using-arrays-to-load-mcs-from-library/301877 "2009-12-17T04:54:13Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![andy\_bramwell73](https://avatars.discourse-cdn.com/v4/letter/a/f14d63/32.png) [@andy\_bramwell73](https://forum.kirupa.com/u/andy_bramwell73)
#### Post date: [December 17, 2009, 4:54am UTC](https://forum.kirupa.com/t/using-arrays-to-load-mcs-from-library/301877/1 "2009-12-17T04:54:13Z")

</div>

Hi, i am a full beginner so this may seem stupid!!  
basically i’m creating a little movie player. i have 3 buttons on stage that when clicked i want to load a movie clip from the library into my “container” MC already on stage. basically i want it so when i click on a button it changes the first and only array item to the one i want to load. therefore replacing the existing one. (so there is only one in the container at a time).  
here is what i have . . .

var buttonOn1:button1 = new button1();  
var buttonOn2:button2 = new button2();  
var buttonOn3:button3 = new button3();  
var container2:container = new container();  
var rectangleOn1:rectangle = new rectangle();  
var rectangleOn2:rectangle2 = new rectangle2();  
var rectangleOn3:rectangle3 = new rectangle3();  
addChild(buttonOn1);  
addChild(buttonOn2);  
addChild(buttonOn3);  
addChild(container2);  
buttonOn1.x = 0;  
buttonOn2.x = 200;  
buttonOn3.x = 400;  
container2.y = 150;

var myArray:Array = [];  
myArray[0] = rectangleOn1;  
buttonOn1.addEventListener(MouseEvent.MOUSE\_UP, buttonOn1Do);  
function buttonOn1Do (event:MouseEvent):void {  
myArray[0] = rectangleOn1;  
container2.addChild(myArray);  
}  
buttonOn2.addEventListener(MouseEvent.MOUSE\_UP, buttonOn1Do);  
function buttonOn2Do (event:MouseEvent):void {  
myArray[0] = rectangleOn2;  
container2.addChild(myArray);  
}  
buttonOn3.addEventListener(MouseEvent.MOUSE\_UP, buttonOn1Do);  
function buttonOn3Do (event:MouseEvent):void {  
myArray[0] = rectangleOn3;  
container2.addChild(myArray);  
}

by all means laugh at me if its overly complicated and im doing totally the wrong thing!

this doesnt work at all!!!

Andy
