# Question using action for buttons

**URL:** <https://forum.kirupa.com/t/question-using-action-for-buttons/20806>\
**Category:** Uncategorized\
**Created:** [May 13, 2003, 4:55pm UTC](https://forum.kirupa.com/t/question-using-action-for-buttons/20806 "2003-05-13T16:55:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![knarf53](https://avatars.discourse-cdn.com/v4/letter/k/c37758/32.png) [@knarf53](https://forum.kirupa.com/u/knarf53)\
**Post date:** [May 13, 2003, 4:55pm UTC](https://forum.kirupa.com/t/question-using-action-for-buttons/20806/1 "2003-05-13T16:55:35Z")

</div>

Newbie,

Already have:  
Down loaded a fla code to flash 5 on a generating 6 lotto numbers.  
What it does is there is a button you press and in six different squares it generates six random numbers for lotto.

Problem:  
Lotto decided to change to 5 numbers and include a bonus ball.  
random numbers are 1-44 and on the bonus ball 1-44

What I’m trying to do:  
Add a button to have one of the six squares generate a number 1-44( they can repeat) and keep the button that generates the other 5 numbers.

I’m trying to rewrite the action code to make it happen but no success.

I’m having trouble with understanding how the empty square(empty),(display) receives the command from the button??  
And what do I have to do to the action code to generate the the numbers.

Do I make any sense???  
Well thank in advance  
did attach the fla lotto

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 19, 2003, 2:22pm UTC](https://forum.kirupa.com/t/question-using-action-for-buttons/20806/2 "2003-05-19T14:22:37Z")

</div>

Hi,  
Yes, you ( sorta) make sense, but would be able to help if you post your code or fla

SteveD

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 19, 2003, 5:08pm UTC](https://forum.kirupa.com/t/question-using-action-for-buttons/20806/3 "2003-05-19T17:08:46Z")

</div>

Steve,

since this is my first time on this forum, I thought I had up loaded the file when it ask me to.

I just like to say that some times as we are trying to learn we seek an easy and fast solution to our own problems. We are anxious to get the movie running and it’s easier to ask than spend time experimenting with flash. There are two very important tools that is a must for the beginner Flash person: patience and persistence. After being persistent I was able to get the movie rolling.

Whether it is the right way or the easiest I don’t know, I let you be the judge.

The first file will be the original, the next file is an edit of the FLA.

Scene 1  
Layer 2  
frame 1  
Layer 1  
frame 1  
actions for frame 1  
stop ();  
title  
(empty), (display1)  
(empty), (display2)  
(empty), (display3)  
(empty), (display4)  
(empty), (display5)  
(empty), (display6)  
button  
actions for button  
on (press, release) {  
gotoAndPlay (2);  
}  
[fjohn106@costarica.net](mailto:fjohn106@costarica.net), (Times New Roman, 16 pts)  
url  
selections  
frame 2, (Shuffle)  
actions for frame 2  
i = 1;  
numcells = 49;  
while (Number(i)\<=Number(numCells)) {  
set (“cell” add i, i);  
i = Number(i)+1;  
}  
i = 1;  
while (Number(i)\<=Number(numCells)) {  
set (“random” add i, random(1000));  
i = Number(i)+1;  
}  
lo = 1;  
up = numCells;  
while (Number(up)\>Number(lo)) {  
i = lo;  
j = lo;  
while (Number(i)\<Number(up)) {  
if (get(“random” add i) \> get(“random” add (i+1))) {  
temp = get(“random” add i);  
set (“random” add i, get(“random” add (i+1)));  
set (“random” add (i+1), temp);  
temp = get(“cell” add i);  
set (“cell” add i, get(“cell” add (i+1)));  
set (“cell” add (i+1), temp);  
j = i;  
}  
i = Number(i)+1;  
}  
up = j;  
i = up;  
while (Number(i)\>Number(lo)) {  
if (get(“random” add i) \< get(“random” add (i-1))) {  
temp = get(“random” add i);  
set (“random” add i, get(“random” add (i-1)));  
set (“random” add (i-1), temp);  
temp = get(“cell” add i);  
set (“cell” add i, get(“cell” add (i-1)));  
set (“cell” add (i-1), temp);  
j = i;  
}  
i = i-1;  
}  
lo = j;  
}  
display1 = get(“cell1”);  
display2 = get(“cell2”);  
display3 = get(“cell3”);  
display4 = get(“cell4”);  
display5 = get(“cell5”);  
display6 = get(“cell6”);  
stop ();  
title  
(empty), (display1)  
(empty), (display2)  
(empty), (display3)  
(empty), (display4)  
(empty), (display5)  
(empty), (display6)  
[fjohn106@costarica.net](mailto:fjohn106@costarica.net), (Times New Roman, 16 pts)  
url  
actions for url  
on (press, release) {  
getURL (“[http://www.costaricaescorts.com/index.htm](http://www.costaricaescorts.com/index.htm)”);  
}  
selections  
button  
actions for button  
on (press, release) {  
gotoAndPlay (2);  
}  
Symbol Definition(s)  
title  
Layer 1  
frame 1  
Lotto Picker 6/49, (Times New Roman, 28 pts)  
button  
Layer 1  
Up  
url  
Layer 1  
frame 1  
[http://www.costaricaescorts.com](http://www.costaricaescorts.com), (Times New Roman, 12 pts)  
selections  
Layer 1  
frame 1  
Click here for selections, (TextField7), (Times New Roman, 18 pts)

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@  
And here’s what I did  
I counldn’t figure how to send the number to the text box.  
Got it  
and Got this “how to” from this forum

button  
frame 1  
Push Button Green  
actions for Push Button Green  
on (release) {  
bb=Math.floor (Math.random() \* (45 - 1))+1; ;  
}  
Push Button Yellow  
actions for Push Button Yellow  
on (release) {  
gotoAndPlay (2);  
}  
Bonus Ball, (Times New Roman, 16 pts)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 19, 2003, 5:34pm UTC](https://forum.kirupa.com/t/question-using-action-for-buttons/20806/4 "2003-05-19T17:34:52Z")

</div>

Just up loaded them.

Just in case some one is interested in what they looks like  
here they are:  
Forum is the updated and the lottopicker is the original

[http://home.stx.rr.com/ccmd/gary/forum.html](http://home.stx.rr.com/ccmd/gary/forum.html)  
[http://home.stx.rr.com/ccmd/gary/lottopicker2.html](http://home.stx.rr.com/ccmd/gary/lottopicker2.html)

thanks

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 19, 2003, 6:19pm UTC](https://forum.kirupa.com/t/question-using-action-for-buttons/20806/5 "2003-05-19T18:19:21Z")

</div>

Hi gary,  
**Forum** looks great, so guess you have sorted your problem now - it works exactly how I would expect a lotto picker to work

Keep up the good work

SteveD
