> Has anybody else encountered this or have an explanation?
>
> J
Figuring out the correct order of class generation is a big problem with
languages such as AS2.
Here's an example for example that doesn't have any "correct" order
possible :
class A {
static var x = 1;
static var y = B.x * 3;
}
class B {
static var x = 2;
static var y = A.x * 5;
}
If you generate A then B, you will have A.y null.
If you generate B then A, you will have B.y null.
That's the same thing for variables initialized outside the class
contructor, since they are initialized as the class initialization and
not at the instance construction, they depend also of the class
generation order.
MTASC has some heuristics to try to figure out the correct
initialization order, but they are just heuristics, they can fail on
some particular cases. You should not rely on any particular
initialization order. But one way to force it is to add a static class ref :
class B {
// ensure that A is generated before B
static var __a = A;
}
However in some cases that might cause loops in class generation
ordering algorithm. At this time, MTASC should display a Warning "loop
in generation for class XXX".
Nicolas
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com