Hi all,

I've been aware of the fact that i can't use import statements in a
superclass and then use the imported class in the subclass, however, I
always thought of it as being an issue with the compiler not knowing it
should import the class when an instance of the imported class was not
defined in the superclass.

Now, when encountering this problem again I thought I could solve it by
simply defining a "dummy" instance in the superclass, but with no
success. The compiler still cant find the class... Is this really the
way it "should" work? Shouldn't you be able to use import statements in
superclasses this way?

Short example:

////////////////////////////////////////////////////////////////////////
///////////////

class a.as:

////////////////////////////////////////////////////////////////////////
///////////////

class package.a
{
        var somevar:Number = 11;
}

////////////////////////////////////////////////////////////////////////
///////////////

class b.as:

////////////////////////////////////////////////////////////////////////
///////////////

import package.a;

class b
{
        var myA:a;
        
        function b()
        {
                myA = new a();
                trace(myA.somevar); //OK (ofcourse)
        }
}

////////////////////////////////////////////////////////////////////////
///////////////

class c.as:

////////////////////////////////////////////////////////////////////////
///////////////

class c extends b
{
        
        var myA:a;
        
        function c()
        {
                myA = new a();
                trace(myA.somevar); //NOT OK (why?)
        }
        
}

Thanks,

Nick


_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to