Skip navigation
Currently Being Moderated

Increasing/decreasing a var using dynamic text

Jun 19, 2012 12:48 AM

Hello and thanks for clicking

 

Now while I am not a complete newbie I am far from an expert in this, so instead of using terms I hardly understand myself I'll just give a rough outline of what I need for this project to work

 

I am currently working on a turn-based point-and-click strategy game in flash. Now like most strategy games gathering resources is important, and in this game there are currently four resource bases, a forest, a gold mine, a lake and a stone mine.

 

What I need is for the player to be able to click on, for example, the forest, in which case a dynamic text will become visible. Now I need the player to be able to insert an ammount of soldiers. That ammount will be sent to claim the resources of the base. So basically I need the ammount that is typed in the dynamic text to be retracted from the "soldiers" var and added to the var representing the soldiers in the forest.

 

Any help on how to achieve this would be appreciated

 

Thanks in advance

 
Replies
  • Currently Being Moderated
    Jun 19, 2012 4:18 AM   in reply to Rudolfusftw

    What problem are you having getting a value entered to be used?  With some form of indication being provided for that text entry (a click of a button), you take the value and utilize it, casting it as a Number or int when doing so.   You should show the code that is giving you a problem.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 19, 2012 5:06 AM   in reply to Rudolfusftw

    A textfield has a "text" property.  So if you have a variable that you want to assign the textfield's entry to, then you assign it using...

     

        yourVariable = textfieldName.text;

     

    If you want that variable to be a Number, then you cast the textfield text as a Number when you assign it to the variable...

     

        yourVariable = Number(textfieldName.text);

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points