A Flash Developer Resource Site

Results 1 to 16 of 16

Thread: Bingo Game Script

Hybrid View

  1. #1
    Junior Member
    Join Date
    Feb 2003
    Posts
    25

    Bingo Game Script

    Hello,
    I am horrible at actionscript and I hope some one can point me in the right direction. I basically have a Bingo card with the numbers called already. If the user clicks (marks) the right winning numbers the user wins. How can I program it to see if all the winning numbers have been clicked?

    **This is for Flash 6.

    Thanks ahead.

  2. #2
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    i usually redirect this type of threads to the Movie section here on Flashkit

    gparis

  3. #3
    Junior Member
    Join Date
    Feb 2003
    Posts
    25
    ok. how come?

  4. #4
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    http://board.flashkit.com/board/showthread.php?t=584396

    if you have a specific question on a script, post the script.

    gparis

  5. #5
    Junior Member
    Join Date
    Feb 2003
    Posts
    25
    Thanks gparis but I'm new to AS so I was looking for a little help as to where to start. Is it an if/then?

  6. #6
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    depends on how you are set so far. Could be an if/else if. Could be an Array, could be a switch(case) could be a for loop, while loop etc. if you have a script post it, if not post a mockup .fla.

    And this search in the Movies section yielded 3 results:
    http://www.flashkit.com/search.php?c...&Submit=Search
    gparis

  7. #7
    Junior Member
    Join Date
    Feb 2003
    Posts
    25
    Thanks. I saw those Bingo files too. Guess I thought it would be simpler than that. I'm really just trying to find out whether four buttons have been clicked or not. I don't need to generate numbers or fill the grid or anything like that.

    Basically have four buttons and I'm trying to find out if they all have been clicked.

    The file is 500k - too big to post.

  8. #8
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    You set variables. set them all to false. Then when you click, set them to true. The validation part would be to verify if they are all true.

    gparis

  9. #9
    Junior Member
    Join Date
    Feb 2003
    Posts
    25
    Ahhh...that's what I'm talking about. Thanks a ton! Sorry for the confusion.

  10. #10
    Junior Member
    Join Date
    Feb 2003
    Posts
    25
    Ok. I'm back with some code. I've read up on a few things and thought this would work but it's still isn't for some reason.

    On the first frame I'm declaring four variables (my buttons) set to false.
    Each button has an action setting it to true.
    Then my checker on the first frame of my mc:
    Buttons.onEnterFrame = function() {
    if (button01==true, button02==true, button03==true, button04==true) {
    _root.gotoAndPlay(5);
    }
    };

    Here is my test .fla. This is for Flash 6.
    Any ideas?

    Thanks!
    Attached Files Attached Files

  11. #11
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    if (button01 && button02 && button03 && button04)

    would be the right syntax.
    saying if(button1) is equivalent to if(button1==true)
    && means 'and'
    that way makes a less long statement.

    gparis

  12. #12
    Junior Member
    Join Date
    Feb 2003
    Posts
    25
    Thanks! I changed that out but still nothing is happening when all the buttons are clicked.

  13. #13
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    root.gotoAndPlay(5) will not in the enterframe (as the playhead will keep on going to that frame and never pass it)

    You'll need to delete the enterFrame first:

    Buttons.onEnterFrame = function() {
    if (button01 && button02 && button03 && button04) {
    delete Buttons.onEnterFrame;
    _root.gotoAndPlay(5);
    }
    };

    gparis

  14. #14
    Junior Member
    Join Date
    Feb 2003
    Posts
    25
    Right now the mc that has the buttons and this script is running on Frame 4 of the main timeline. When all the buttons have been clicked I want it to go to Frame 5 or the next frame in the main timeline.

    Buttons.onEnterFrame = function() {
    if (button01 && button02 && button03 && button04) {
    delete Buttons.onEnterFrame;
    _root.gotoAndPlay(5);
    }
    };


    does this delete my mc? I put it in the 1st frame of the mc but it's still not advancing.

  15. #15
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    1 ) careful with scopes:
    that script above, as is, is supposed to go on the main timeline. (you're talking to Buttons, which i guess is sitting on the main timeline)

    2) the references to the variables buttons, as is, means that these 4 vars are declared ON the main timeline as well. meaning, you declare them all to false:
    Code:
    button01 = button02 = button03 = button04 = false;
    Now your buttons, i assume, are inside the MC Buttons, right?

    So their action should be:
    _root.button01 = true; //same for all 4 buttons: _root.button02 = true; ...etc.

    3) careful with gotoAndPlay(x) : you can't tell the player head to gotoAndPlay() on a frame that has a stop() action on it. You need to decide if it plays or stops.... right?

    gparis

  16. #16
    Junior Member
    Join Date
    Feb 2003
    Posts
    25
    That was it!

    I had button01=true for an action instead of _root.button01-true

    I didn't realize variables were timeline sensitive. Is there a way to use variables globally?

    Thanks gparis.
    Last edited by Kojak2; 01-16-2007 at 02:45 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center