0 Replies Latest reply on Jan 15, 2009 2:38 PM by Llama_Boy

    Using a variable to change a variable

    Llama_Boy
      Hey Everyone,

      Here's the situation. I'm creating a board game which has 3 variables, p1Move, p2Move and activePlayer.
      p1Move and p2Move store the p1 and p2 location on a game board. activePlayer stored who's turn it is at the moment.

      I am loading a value in from a text file which changes the value of move. This all works fine when i designate a player directly:

      p1Move = [insert variable name],
      but i want to designate dynamically based on who's turn it is.

      Something like this:

      _root["p"+activePlayer+"Move"] += Number(this.varAmount);

      so that flash changes the value of p1Move (or p2Move depending on who's turn it is) to varAmount. varAmount is the variable being read from the textfile.

      Hopefully that all makes sense. Basically i want flash to change the variable associated with the active player only.

      Any help would be greatly appreciated, LB