# Clueless newbie looking for AS3 Guru

**URL:** <https://forum.kirupa.com/t/clueless-newbie-looking-for-as3-guru/329495>\
**Category:** flash\
**Created:** [September 6, 2012, 1:11pm UTC](https://forum.kirupa.com/t/clueless-newbie-looking-for-as3-guru/329495 "2012-09-06T13:11:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jomblr](https://avatars.discourse-cdn.com/v4/letter/j/b5e925/32.png) [@jomblr](https://forum.kirupa.com/u/jomblr)\
**Post date:** [September 6, 2012, 1:11pm UTC](https://forum.kirupa.com/t/clueless-newbie-looking-for-as3-guru/329495/1 "2012-09-06T13:11:22Z")

</div>

Hi!

I’m trying to create a simple map game for an upcoming world scout jamboree and I’m in need of some help. I think that my problem is pretty basic, and I’ll try to explain this as simple as possible;

I’ve created an array of three ‘buttons’. Only one button can be active at a time. I’d like to add a function that deactivates a button if I click it again. I’d also like to create a ‘controller button’ that closes all active buttons. I’ve followed an online tutorial and I’ll attach the source file and actionscript in this message and I’d be very grateful for assistance.

- Johan

```auto
/*#######################################################
* Written by: Sorin Haidan
* email: biochimistu@yahoo.com
* blog: http://biochimistu.blogspot.com
############################
############################*/

stage.frameRate = 30;
var buttonsArray:Array = [button_1,button_2,button_3];

function setButtons():void {
    for (var i:int=0; i<buttonsArray.length; i++) {
        buttonsArray*.id = i;
        buttonsArray*.buttonMode = true;
        buttonsArray*.mouseEnabled = true;
        buttonsArray*.addEventListener(MouseEvent.CLICK,doClick);
    }
}

function doClick(event:MouseEvent):void{
    var currentBtn:int = event.currentTarget.id;
    setSelectedBtn(currentBtn);
}
function setSelectedBtn(id:int):void{
    for (var i:int=0; i< buttonsArray.length; i++) {
        if (id == i) {
            buttonsArray*.gotoAndPlay("start");
            buttonsArray*.buttonMode = true;
            buttonsArray*.mouseEnabled = true;
            buttonsArray*.removeEventListener(MouseEvent.CLICK,doClick);
        } else {
            if(buttonsArray*.currentLabel =="start"){
                buttonsArray*.gotoAndPlay("stop");
            }
            buttonsArray*.buttonMode = true;
            buttonsArray*.mouseEnabled = true;
            buttonsArray*.addEventListener(MouseEvent.CLICK,doClick);
        }
        
    }
}
setButtons();

```
