3 Replies Latest reply on Mar 24, 2011 8:32 PM by YueKitsune

    Digital Safe Cracking

    YueKitsune

      I'm working on a project in the Unreal Development Kit (UDK) useing Scaleform GFx. What i plan on doing is having a random number generated by one .swf file, and have a digital key pad for a safe reference that .swf for the safes passcode. Both of these .swf files will be in the level, with the first file that generates the number being on a compter screen or something for the player to find, and the safe with the keypad hidden behind a picture or something.

       

      I've got the code to generate a random number:

       

      display.text = String(Math.floor(Math.random()*99))+10;

       

      and have it in game no problem. display is the name of the dynamic text field that the number appears in. As a side note for anyone who might try and re-create this themselves the code above usually gives a 4 digit number, but 3 digit numbers have poped up.

       

      The .swf for the keypad consists of twelve buttons, 0 through 9, an Enter and Clear button, and a dynamic text field that displays the numbers when you click on the 0 - 9 buttons. I have the numbered buttons working each with this code:

       

      on (release) {
        Button1 += "1";
        total.text += "1";
      }

       

      just replacing 1 with whatever number the button is. total is the name of the dynamic text box that these numbers are shown in.

       

      My current problem is with the Clear button, which as its name suggests should clear total.text. Instead of just clearing the text box it replaces the numbers with "undefined". The code i'm using for the clear button is this:

       

      on(release)
      {
        total.text = total.substring(0, total.length);
      }

       

      I'm guessing that it's not sure what total.length is but nothing i've tried to replace that line with works any better. I'm also anticipating some trouble with the Enter button, but i'll cross that bridge when i get to it.

       

      Any help would be appreciated.

        • 1. Re: Digital Safe Cracking
          Ned Murphy Adobe Community Professional & MVP

          For clearing the textfield you can just use:

           

          total.text = "";

          • 2. Re: Digital Safe Cracking
            YueKitsune Level 1

            I am dumbfounded at how simple that was XD

             

            Thanks, you are turning into the goto guy it seems.

            • 3. Re: Digital Safe Cracking
              YueKitsune Level 1

              Ok, i'm back again, and thanks for all the help so far

               

              Because I plan on having the Enter button check what is in total.text (in the keypad swf) against the random number generated (in the other swf) to see if they match, i figured it'd be a good idea to get the 2 swf files talking first. I'm using localconnection to get the info from one swf to the other and all that works fine, except that it only works if i have a button that does the sending.

               

              I've added a second dynamic text to the keypad (which will be hidden from view once all's said and done) and a button (which i'll remove later) that sends the random number to that text box.

               

              What I need is for the number to be sent whithout having to click the button. Is this even possible? All the examples I can find have a button in one file that sends to the other when pressed.

               

              Once I have this down i'll be making the Enter use an if then code to check and make sure that the 2 text fields in the keypad file are the same, if yes great then open the door, if no try again.