7 Replies Latest reply on Mar 24, 2014 6:35 AM by kglad

    Using strings to go to other scenes

    zoner9

      Hi, I'm having a bit of a problem:

       

      I'm trying to use an input text field as a cheat code input to move between 2 different scenes - if the code is correct, I want to go to one scene, but if the code is not correct, I want to go to a different scene. At the moment, no matter what I put into the text field, I end up going to the scene that's supposed to be for incorrect codes - even when I enter the correct code.

       

      The code I'm using:

       

      stop();

      //stops on this scene

      {

      var cheat:String = "Enter Code Here";

      //declaring a variable for a cheat code

      _root.cheatBox.cheat = cheat;

      //sets the text of the cheat box to cheat

      _root.menuButton.onRelease = function()

      //when the menu button is released

      {

        gotoAndStop("Menu", 1);

        //goes to menu scene and stops on that scene

      }

      _root.cheatBox.goButton.onRelease = function()

      //when the go button in the cheat box is released

      {

        if(_root.cheatBox.cheat == "N0496151")

        //if the text box contains the code

        {

         gotoAndStop("Cheat", 1);

         //goes to the cheat scene and stops on that scene

        }

        else if(_root.cheatBoxcheat != "N0496151")

        //otherwise

        {

         gotoAndStop("Menu", 1);

         //goes to the menu scene and stops on that scene

        }

      }

      }

       

      All of this code is on the main timeline, is there something I'm not doing right?