# addChild() does not work for a button within a class

**URL:** https://forum.kirupa.com/t/addchild-does-not-work-for-a-button-within-a-class/329930
**Category:** flash
**Created:** [November 9, 2012, 5:08am UTC](https://forum.kirupa.com/t/addchild-does-not-work-for-a-button-within-a-class/329930 "2012-11-09T05:08:11Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Yo\_Rikas](https://avatars.discourse-cdn.com/v4/letter/y/ce73a5/32.png) [@Yo\_Rikas](https://forum.kirupa.com/u/Yo_Rikas)
#### Post date: [November 9, 2012, 5:08am UTC](https://forum.kirupa.com/t/addchild-does-not-work-for-a-button-within-a-class/329930/1 "2012-11-09T05:08:11Z")

</div>

Hi

I’m trying to build a simple slot machine. I’ve made a class SlotMachine, a class SlotReel. I create the reels instances inside the SlotMachine class and they appear on stage. But when I try to add a button it won’t appear. Here is the relevant code inside the SlotMachine class:

```auto
private var spinButton:SimpleButton = new SimpleButton();
        

        public function SlotMachine() {
            this.addChild(spinButton);
            spinButton.addEventListener(MouseEvent.CLICK, this.spinSlotMachine);
            spinButton.x=spinButton.y=0;
        }// constructor ends

```

This does not return any errors, but the button doesn’t appear. I work on Flash CS4. Thanks in advance!
