Skip to main content
Participating Frequently
March 19, 2015
Answered

Create a counter in AS3

  • March 19, 2015
  • 1 reply
  • 341 views

Hi I am busy building an escape the room type game where the user must find 6 items in a room before they can leave the room.  I have almost build the room however I want to include a counter that displays how many items have been found.  So when a item is found on the stage the counter would increase by one until a target is reached at which point the user would be able to exit the room.  Any ideas how i would code this counter??

This topic has been closed for replies.
Correct answer kglad

it looks like this:

itemNum++;

1 reply

kglad
Community Expert
Community Expert
March 19, 2015

assign a variable to track the items and initialize it to zero when a room is entered (if that's what you want):

var itemNum:int = 0;

increment the counter when an item is found:

itemNum++;

RidleylAuthor
Participating Frequently
March 19, 2015

I have created the variable and set to 0.  However i'm not sure how to get it to add one when an item on the stage is clicked on??  What would this look like??  Any help would be great

Thanks in anticipation

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
March 19, 2015

it looks like this:

itemNum++;