I have a simple game that allows the player to drag counters around a board (just a background image).
There are 23 counters created in the main .as class by calling another class, called “Units.as”. The counters are added into an array in the main class like this:
counterarray[0] = new Units(“1”,2);
(where “1” and 2 define the label and colour of the counter)
I do this for all 23 counters.
I then define a position for the counters
counterarray[0].x = 100;
counterarray[0].y = 50;
.
… and so on up to counterarry[22]
finally, I loop to place them:
for(i:int=0;i<counterarray.length;i++) {addChild(counterarray);}*
The class Units.as defines the counters as rectangles and places mouse listeners so they can be dragged around.
My problem: I want to save the information about the counters to a shared object, but if you move a counter around, the counterarray[0].x and .y remain stubbornly where I originally set them - as 100 and 50.
I tried passing the x and y co-ordinates to Units (e.g. counterarray[0] = new Units(“1”,2,100,50); ) but while this works for placing the units, the value of counterarray[0].x is now zero and doesn’t change when the counter is dragged around.
I’ve only been using AS3 for a couple of weeks so suspect I am missing something obvious, but I’ve spent the last couple of days searching the internet & can’t find it.
I am coding in SciTE and compiling with flex sdk.