Static variables are not inherited by subclasses in ECMAScript therefore can not be referenced through derived class objects. This differs from Java and C#.

James O'Reilly  —  Consultant
Adobe Certified Flash Expert
http://www.jamesor.com
Design • Code • Train



[EMAIL PROTECTED] wrote:
Hi all. It's been a LONG time since I've posted and now I need your help
again.

I have come across something that to me doesn't seem correct and I don't
know why things are behaving this way. I have 2 classes, one a subclass of
the other. Both have public static variables (AS2.0 Flash 7).

class mypackage.Fruit {
    public static var COLOR:Number = 0;
}

class mypackage.Orange extends mypackage.Fruit {
   public static var SEEDS:Number = 0;
}

Now in the Orange class or any other class that needs to use Orange. The
following code: Orange.COLOR returns 0.

import mypackage.Orange;
class Table {
   public function Table() {
      trace("Orange.COLOR: " + Orange.COLOR); // outputs 0
   }
}

Things change when this code is applied to the timeline:

Table.fla
import mypackage.Orange;
trace("Orange.COLOR: " + Orange.COLOR); // outputs undefined
trace("Orange.SEEDS: " + Orange.SEEDS); // outputs 0

Tracing Orange.COLOR gives me undefined. But if I import mypackage.Fruit.
Fruit.COLOR traces out 0.

Table.fla
import mypackage.Fruit;
trace("Fruit.COLOR: " + Fruit.COLOR); // outputs 0

Can someone shed some light on why in an FLA that the subclass (in this
case Orange) cannot access its super class static variables
(Orange.COLOR)?

Thanks.
\m/
_______________________________________________
[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

_______________________________________________
[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

Reply via email to