# Button array

**URL:** <https://forum.kirupa.com/t/button-array/304058>\
**Category:** Uncategorized\
**Created:** [January 31, 2010, 10:08pm UTC](https://forum.kirupa.com/t/button-array/304058 "2010-01-31T22:08:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Luigi\_Vercotti](https://avatars.discourse-cdn.com/v4/letter/l/b2d939/32.png) [@Luigi\_Vercotti](https://forum.kirupa.com/u/Luigi_Vercotti)\
**Post date:** [January 31, 2010, 10:08pm UTC](https://forum.kirupa.com/t/button-array/304058/1 "2010-01-31T22:08:14Z")

</div>

Hello 😉  
I’m trying to do array button or simplify this code…

> 

function popupWindow1(event:MouseEvent):void {

```
var desiredURL:URLRequest = new URLRequest("javascript:NewWindow=window.open('http://www.suziklinik.cz/radek/1.htm','newWin','width=750,height=300,left='+((screen.width/2)-(360))+',top='+(screen.height/2)+',toolbar=No,location=No,scrollbars=Yes,status=No,resizable=Yes,fullscreen=No'); NewWindow.focus(); void(0);");

navigateToURL(desiredURL, "_self");
trace ("buttone funguje");

```

}  
day\_1.addEventListener(MouseEvent.CLICK, popupWindow1);

function popupWindow2(event:MouseEvent):void {

```
var desiredURL:URLRequest = new URLRequest("javascript:NewWindow=window.open('http://www.suziklinik.cz/radek/den_2.htm','newWin','width=750,height=300,left='+((screen.width/2)-(360))+',top='+(screen.height/2)+',toolbar=No,location=No,scrollbars=Yes,status=No,resizable=Yes,fullscreen=No'); NewWindow.focus(); void(0);");

navigateToURL(desiredURL, "_self");
trace ("buttone funguje");

```

}  
day\_2.addEventListener(MouseEvent.CLICK, popupWindow2);

function popupWindow3(event:MouseEvent):void {

```
var desiredURL:URLRequest = new URLRequest("javascript:NewWindow=window.open('http://www.suziklinik.cz/radek/den_3.htm','newWin','width=750,height=300,left='+((screen.width/2)-(360))+',top='+(screen.height/2)+',toolbar=No,location=No,scrollbars=Yes,status=No,resizable=Yes,fullscreen=No'); NewWindow.focus(); void(0);");

navigateToURL(desiredURL, "_self");
trace ("buttone funguje");

```

}  
day\_2.addEventListener(MouseEvent.CLICK, popupWindow3);

what am I coding wrong?

> 

function popupWindow(event:MouseEvent):void {

```
var desiredURL:URLRequest = new URLRequest("javascript:NewWindow=window.open('http://www.suziklinik.cz/radek/1.htm','newWin','width=750,height=300,left='+((screen.width/2)-(360))+',top='+(screen.height/2)+',toolbar=No,location=No,scrollbars=Yes,status=No,resizable=Yes,fullscreen=No'); NewWindow.focus(); void(0);");

navigateToURL(desiredURL, "_self");

```

}

var btns:Array = new Array(“day\_1”, “day\_2”, “day\_3”);//instante name of buttons on the stage

for (var i:int = 0; i \< btns.length; ++i){  
btns\*.addEventListener(MouseEvent.CLICK, popupWindow);  
}
