Creating a game, and I need help with some coding

7 posts

Flag Post

i have just installed flash 9.0 on my computer and want to create a basic game, the things i want to know how to do is:

(Note: this list may be edited and checked off as i progress)

2. Create a button that, when clicked, adds one to a counter

3. A counter that when reaches a certain number, displays text in a predetirmined textbox

3b. A way to display the counter to the player

4. How to change that text without it repasting itself over and over again-CHECK!

NEW! 5. How to end A.S.3 script

P.S. a name or username of your choice will be displayed in the opening frame

P.P.S I am using Actionscript 3.0

P.P.P.S Thank you in advance

 
Flag Post

1) I dont get what your trying to do???
2)put this in the frame with the button:


i=0;
button.onRelease = function()
{
i++; //saying that “i” is the counter
}

3) Adding to the previous code put:

i=0;
button.onRelease = function()
{
i++; //saying that “i” is the counter
if(i==10)
{
text = “BLAH”;
}

4) Just change the “BLAH” part
P.P.S Im not sure if its the same in AS 3.0
}

 
Flag Post

if that works in as3, you will recieve credentials in my game

 
Flag Post

First of all, I’m just going to put this out there: I personally like AS2 WAY better. AS3 I’m sure is better from a technical standpoint, but AS2 allows for many useful shortcuts, and in my opinion it is better suited for game development.

Anyways…

In the first frame of your game, put this code: _global.count=0
That will make a variable that is accessible from anywhere in the game, which later on could prove useful. First make a dynamic text box on the stage and give it an instance name of “texty”. Then make a button, and insert this code:

on(release){

  • _global.count++
  • if(_global.count==10){
  • _root.texty.text=“message”;
  • }
    }

This code will increase the counter by 1. It then checks to see if the count is 10, and if that’s true it adds text to the text box you made earlier, replacing anything currently in the text box.

I’m not sure if that will work in AS3, it’s probably very similar if it does not.

 
Flag Post

I am now using AS2

 
Flag Post

AS2 (I may have Flash CS3 but I’m too lazy to learn AS3):

2.

score = 0;
btn.onRelease = function() { score++; }

Make sure you have a button and call the instance name “btn”

3.

if (score == 1) { lol.txt = “Apples” }

lol is a dynamic textbox. Write “lol” as the textbox’s instance name.

4. Change the number and write something different in that quote.

 
Flag Post

for ps i believe you could use an input text box set it’s variable to name then on the main menu have a dynamic text box with the variable name. (i haven’t tested this but i think it should work)
EDIT: just tested it it works fine but make sure you put a line/box around the text box