Classes

Right, I haven’t touched AS in a few months now so now I have returned to it I am just as lost when I first started lol.

I think of classes as a way to reuse the same code but creating different things. So for example a class called Items which gives the traits for all things created by that class, they are all an Item but all differ slightly.

So I quickly went off to make a class;
[AS][COLOR=#000000]class Test {
var number:Number;
public function getTrace() {
number = Math.round(Math.random()*1000);
trace(number);
}
}[/AS][/COLOR]

And made a swf;
[AS]var Test:Test = new Test();
var Test3:Test = new Test();
var Test2:Test = new Test();

_root.Test3.getTrace();
_root.Test2.getTrace();
_root.Test.getTrace();[/AS]

But I only get one trace given to me, but if I swap the order so it goes Trace 3, then 2 then 1 I get three traces as I want. I think I have misunderstood something simple :crying: Why does it do that? I just wanted 3 different items to do the same thing, like 3 swords which you can all pickup, sell equip etc etc.