Skip to main content
Inspiring
October 5, 2011
Question

counter question

  • October 5, 2011
  • 1 reply
  • 560 views

hey folks,

Been learning quite a lot over my time in here. I'm hoping to get some direction before I start my next little exercise. This way I can do it right from the start. Really creating a very basic sorting exercise. two sides of the screen. If you drag something to the left it'll display a 1 in the top left corner, put something on the right it'll display 1. Ten items. Now the dragging and what not I've got ready to go. My train of thought is to create the numbers as mcs. So if you drag the item over to the left, a "1" mc will appear in the top left. Is this an efficient way or do any of the experts know a better way? Any direction would be great.

This topic has been closed for replies.

1 reply

Ned Murphy
Legend
October 5, 2011

Use textfields and counter variables, incrementing the variables and assigning their values to the textfields each time you drop an item.

Inspiring
October 5, 2011

thanks ned...is there any sort of tutorial on this? counter variables are new to me

Ned Murphy
Legend
October 5, 2011

A counter variable is nothing special... just a variable that you treat as a Number.

var aCounter:Number = 0;

There's one for you!  So when you want to add 1 to it you can use...

aCounter++;

OR

aCounter += 1;

OR

aCounter = aCounter + 1;

And if you want to assign that value to a textfield that you happen to name tField...

tField.text = String(aCounter);