# Assign values to buttons

**URL:** <https://forum.kirupa.com/t/assign-values-to-buttons/305390>\
**Category:** Uncategorized\
**Created:** [February 24, 2010, 2:25pm UTC](https://forum.kirupa.com/t/assign-values-to-buttons/305390 "2010-02-24T14:25:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tourbike](https://avatars.discourse-cdn.com/v4/letter/t/a9adbd/32.png) [@tourbike](https://forum.kirupa.com/u/tourbike)\
**Post date:** [February 24, 2010, 2:25pm UTC](https://forum.kirupa.com/t/assign-values-to-buttons/305390/1 "2010-02-24T14:25:09Z")

</div>

hello, I am new top actionscript that is why I am trying to learn AS3 instead of the AS2 etc. anyway I am trying to create a number pad in flash (like a calculator but wothout the add, subtract etc) so that when I press a number its displays the number in the flash movie. I nearly have it but it only displays one number at any one moment but i need to be able to add upto 5 digits in the display, so that later on in the project I can validate this field to make the input is correct.

here is the code that I have made but remember this is my first AS3 flash program so go easy on me 😃

stop();

display.maxChars = 5;

// start of the array  
Digit1.addEventListener(MouseEvent.CLICK,valueone);  
Digit2.addEventListener(MouseEvent.CLICK, valuetwo);  
Digit3.addEventListener(MouseEvent.CLICK, valuethree);  
Digit4.addEventListener(MouseEvent.CLICK, valuefour);  
Digit5.addEventListener(MouseEvent.CLICK, valuefive);  
Digit6.addEventListener(MouseEvent.CLICK, valuesix);  
Digit7.addEventListener(MouseEvent.CLICK, valueseven);  
Digit8.addEventListener(MouseEvent.CLICK, valueeight);  
Digit9.addEventListener(MouseEvent.CLICK, valuenine);  
Digit0.addEventListener(MouseEvent.CLICK,valuezero);  
Digitclear.addEventListener(MouseEvent.CLICK,valueclear);

//On mouse out function  
function valueone(event:MouseEvent):void {  
display.text = “1”;  
}

//On mouse out function  
function valuetwo(event:MouseEvent):void {  
display.text = “2”;  
}

//On mouse out function  
function valuethree(event:MouseEvent):void {  
display.text = “3”;  
}

//On mouse out function  
function valuefour(event:MouseEvent):void {  
display.text = “4”;  
}

//On mouse out function  
function valuefive(event:MouseEvent):void {  
display.text = “5”;  
}

//On mouse out function  
function valuesix(event:MouseEvent):void {  
display.text = “6”;  
}

//On mouse out function  
function valueseven(event:MouseEvent):void {  
display.text = “7”;  
}

//On mouse out function  
function valueeight(event:MouseEvent):void {  
display.text = “8”;  
}

//On mouse out function  
function valuenine(event:MouseEvent):void {  
display.text = “9”;  
}

//On mouse out function  
function valuezero(event:MouseEvent):void {  
display.text = “0”;  
}

//On mouse out function  
function valueclear(event:MouseEvent):void {  
display.text = “”;  
}

I am trying to research how to do it and have posted this problem on other forums but no one is will to point in the right direction but if anyone can then thanks alot

cheers

tourbike

p.s. I have attached an image with this post to help explain what I am trying to do
