# Actionscript quiz

**URL:** <https://forum.kirupa.com/t/actionscript-quiz/2618>\
**Category:** Uncategorized\
**Created:** [May 22, 2002, 6:42pm UTC](https://forum.kirupa.com/t/actionscript-quiz/2618 "2002-05-22T18:42:00Z")\
**Posts on this page:** 10\
**Page:** 1

<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 22, 2002, 6:42pm UTC](https://forum.kirupa.com/t/actionscript-quiz/2618/1 "2002-05-22T18:42:00Z")

</div>

well… I really have no other reason for this excercise other than to try to do it. I have gotten this far… with your help (thanks, Supra), but it is obviously missing functionality. Now, since you guys are NERDS, just like me… Im looking for some code suggestions.

Basically, I’d like the code to calculate a win. I’m sure you’re familiar with the game… all numbers down, across, or diagonal is a win, but I’m not sure how to go about it.

The swf is here: [www.realinteresting.com/k…m\_test.swf](http://www.realinteresting.com/kirupa/bingo/gm_test.swf)

the fla is here: [www.realinteresting.com/k…m\_test.fla](http://www.realinteresting.com/kirupa/bingo/gm_test.fla)

well, what do you think?

---

<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 23, 2002, 4:18am UTC](https://forum.kirupa.com/t/actionscript-quiz/2618/2 "2002-05-23T04:18:44Z")

</div>

That’s pretty cool. Still thinking, myself…

are your numbers stored in an array?

---

<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 23, 2002, 11:51am UTC](https://forum.kirupa.com/t/actionscript-quiz/2618/3 "2002-05-23T11:51:59Z")

</div>

numbers are stored in arrays…

bvalue  
ivalue  
nvalue  
gvalue  
ovalue

perhaps I should concat into a new array?

---

<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 23, 2002, 12:05pm UTC](https://forum.kirupa.com/t/actionscript-quiz/2618/4 "2002-05-23T12:05:07Z")

</div>

Well, you could make it like a real Bingo thing, and make them click on the number that appears. So make a button, or put a movieclip over each box and when they get that number they click and the box changes color, but you would also change the value of a variable…and then have flash detect to see if a bunch of variables are true have it check for like:

b1win  
b2win  
b3win  
b4win  
b5win

or something like that…i’m sure there is an easier way but right nwo all ic an think of is this…

---

<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 23, 2002, 2:35pm UTC](https://forum.kirupa.com/t/actionscript-quiz/2618/5 "2002-05-23T14:35:51Z")

</div>

I created a movie clip and put the movie clips “behind” each number slot on the card. I set the visibility to false.

I created a new array that holds all the number values for the card. Now, I just have to figure out how to compare a value against all the values in that array.

That way, if the number exists in the array, the visibility of the mc on the correct slot will be set to true.

---

<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 23, 2002, 6:46pm UTC](https://forum.kirupa.com/t/actionscript-quiz/2618/6 "2002-05-23T18:46:10Z")

</div>

(This message was left blank)

---

<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 23, 2002, 7:11pm UTC](https://forum.kirupa.com/t/actionscript-quiz/2618/7 "2002-05-23T19:11:36Z")

</div>

how about using multi dimensional arrays?

```auto
  
bingo = [
   [45,76,26,97,23],
   [85,28,95,26,64],
   [39,217,7,60,35],
   [6,87,34,27,56],
   [32,9,20,56,31]
];

```

then mirror it for your hits:

```auto
  
hits = [[],[],[],[],[]];

```

and mark off the hits as they’re drawn:

```auto
  
for(j in bingo){
   for(k in bingo[j] ){
      if(bingo[j][k] == drawnNumber){
         hits[j][k] = 1; // plus mark the sqaure or something
         if(hits.checkBingo(j,k)) trace("BINGO!");
      }
}

```

then checking vertical and horizontal is easy:

```auto
  
Array.prototype.checkBingo = function(j,k){
   var check;
   // check the row
   for(n in this[j]){ check+=this[j][n]; };
   if(check == 5) return true;
   check = 0;
   // check the column
   for(n in this){ check += this[n][k]; };
   if(check == 5) return true;
   return false;
}

```

the diagonals i’ll leave to you. too hard! 😉

this is untested so most likely has bugs in it.

- edit\* boy that italics thing is annoying…

---

<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 23, 2002, 8:22pm UTC](https://forum.kirupa.com/t/actionscript-quiz/2618/8 "2002-05-23T20:22:26Z")

</div>

Dude… you are FREAKIN me ouT!

thanks for the reply…

I’ll go get me another box of ColonBlow (SNL reference) and try to work this one out.

You crack me up. You really do. I appreciate the help! I guess if my questions are getting harder, the answers get harder too.

---

<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 23, 2002, 9:03pm UTC](https://forum.kirupa.com/t/actionscript-quiz/2618/9 "2002-05-23T21:03:12Z")

</div>

you know, i’d probably just hard code the diagonal check, and check everytime regardless of which square was being marked.

```auto
 
Array.prototype.diagBingoCheck = function(){
   var c,j=0; var k=5;
   while(k--){
      c += this[j++][k];
   if(c==5) return true;
   c=0;
   while(j--){
      c += this[j][k++];
   }
   if(c==5) return true;
   return false;
}

```

---

<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 23, 2002, 9:12pm UTC](https://forum.kirupa.com/t/actionscript-quiz/2618/10 "2002-05-23T21:12:02Z")

</div>

actually, even cooler. you can tell if the square is on a diagonal because either j will equal k, or j+k will equal 4. so we can add to checkBingo:

```auto
 
Array.prototype.checkBingo = function(j,k){
   var check;
   // check the row
   for(n in this[j]){ check+=this[j][n]; };
   if(check == 5) return true;
   check = 0;
   // check the column
   for(n in this){ check += this[n][k]; };
   if(check == 5) return true;
   if(j==k || j+k == 4) return( this.diagCheckBingo(); );
   return false;
}

```
