A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: The Vault

  1. #1
    Member
    Join Date
    Dec 2003
    Posts
    99

    The Vault

    Hey there I have started to learn how to program games in flash and I am an absolute beginner. I have game up with a game called "Vault" about a person who has to open many locked vaults in order to reach a bomb. They must diffuse the bomb to save a certain building and a certain number of people.

    So I have my story line. I have started the coding for the project. The first vault is a 4 Digit pin number. Now you have an interface where you control the digits. Something like this:

    + + + +

    0 0 0 0

    - - - -

    the 0's equal the digits (from 0-9). Now i have a button your press to unlock the coded vault. i also have four lights (white when wrong digit is present, but turn green when a correct digit is present). Something like mastermind or code master.

    The code for the unlock button is this:

    on (release) {
    if (cv1==9) {
    _root.cva1.gotoAndPlay(2);
    if (cv2==3) {
    _root.cva2.gotoAndPlay(2);
    if (cv3==3) {
    _root.cva3.gotoAndPlay(2);
    if (cv4==7) {
    _root.cva4.gotoAndPlay(2);
    }
    }
    }
    } else {
    _root.cva1.gotoAndPlay(1);
    _root.cva2.gotoAndPlay(1);
    }
    }

    so as you can see the code should read 9337 and then it will go to frame 2. Also the light will go green if the digit in the order is present.

    However say if i enter 9 in the first digit box the light goes green after pressing unlock. However if i press unlock again it goes white. What could be the problem?

    I have attached the swf to show you the set up. Code is 9337.

    SWF FILE
    This is so non hanous!

  2. #2
    Member
    Join Date
    Dec 2005
    Posts
    60
    woah it has another error: if you press the right one and than the wrong one the green acces codes are messed up!

    I do not understand why u use gotoAndPlay. You code should be kinda this:

    var codeiscorrect:Boolean;
    if(numbers are correct) {
    codeiscorrect=true;
    }else{
    codeiscorrect=false;
    }if(codeiscorrect) {
    goto.yournextchallenge
    }

    You should post a more detailed question or a .fla. It is not that hard to solve it but get rid of you gotoAndPlay command for this game!

    Good luck!

  3. #3
    Member
    Join Date
    Dec 2003
    Posts
    99
    ok i looked at the code and got everything apart from these two parts:

    on (release) {
    var codeiscorrect:Boolean;
    if(numbers are correct) {
    codeiscorrect=true;
    }else{
    codeiscorrect=false;
    }if(codeiscorrect) {
    _root.gotoAndPlay(2);
    }
    }

    I know a Boolean is a string of numbers so obviously I am setting upo a string of numbers to set the codeiscorrect variable. However what do i put in the seconf bolded bit in the code? Do i put my four digit code? Im lost...

    also how do i make the green lights work properly. Im not looking for my whole game to be coded but I am looking for this to be sorted so i can use the basics of this code to help in further levels.

    I am thankful of all help so far...
    This is so non hanous!

  4. #4
    Senior Member Ray Beez's Avatar
    Join Date
    Jun 2000
    Posts
    2,793
    Quote Originally Posted by TedTLogan
    I know a Boolean is a string of numbers so obviously I am setting upo a string of numbers to set the codeiscorrect variable. However what do i put in the seconf bolded bit in the code? Do i put my four digit code? Im lost...
    No, a Boolean is a logical operation or state:
    http://dictionary.reference.com/search?q=boolean

    Usually it's a variable that will be true or false.

    Basically, he's trying to set you up with some general logic, without just handing script over.

    You need to attack this bit by bit. Put your game aside for a moment and try to write script that sets a movieclip to a particular frame. For example make it with two states, one red and one green. If you can get far enough where you can set that clip to go to whatever color you want, then go ond step further and try doing it using a variable and an IF statement.

    Keep going and try to solve the little parts of what your game will need, then in the end you'll have all the little parts that you can put together to make your game.

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