# Changing the color button each time to press

**URL:** <https://forum.kirupa.com/t/changing-the-color-button-each-time-to-press/163730>\
**Category:** Uncategorized\
**Created:** [September 25, 2005, 6:11pm UTC](https://forum.kirupa.com/t/changing-the-color-button-each-time-to-press/163730 "2005-09-25T18:11:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![flash\_legend](https://avatars.discourse-cdn.com/v4/letter/f/2acd7d/32.png) [@flash\_legend](https://forum.kirupa.com/u/flash_legend)\
**Post date:** [September 25, 2005, 6:11pm UTC](https://forum.kirupa.com/t/changing-the-color-button-each-time-to-press/163730/1 "2005-09-25T18:11:49Z")

</div>

good day members

i have a button when i press the button the color will change to black and then when i press it again it will change to yellow and then again when i press it . it will change to blue

i design the button and i gave it name in the instance name as myButton

i tried with this code ( i put the code on the time line ) . it change the color to black BUT when i tried to change it to yellow NOTHING

this is the code

```auto

button_color = new Color(_root.myButton);
_root.myButton.onPress = function() {
    if (_root.myButton!=button_color) {
        button_color.setRGB(0x000000);
    }
};

```

any help guys

thank you
