mercredi 24 février 2016

Error 1119 when using Inspectable in class extending a parent also with Inspectable properties

Short description:

I have a class C which is extending a class P. Class P has a few Inspectable properties.

I added a few Inspectable properties to class C, linked C to a component in library and added C as the class of the Component Definition of that component. I could, at that point, read and set the Inspectable properties(that belong to P and C) of the instances of that component that were on stage through Component Parameters section of Properties window.

However, if I set even a single Inspectable property of class C through Component Parameters, when I try to export an .swf, I get a different compiler error 1119 for each Inspectable property of C(even if I did not set it and left its default value), saying that I am referencing possibly undefined property childProperty through a reference with static P.

Detailed description:

I have a class ChildClass, which extends a class ParentClass and I am trying to declare a few public attributes of ChildClass as Inspectable. ParentClass, too, has a few Inspectable getters and setters helping access corresponding protected attributes in the parent.

For the sake of completeness, consider that there is an inspectable property of ChildClass named childProperty. Consider also that there is an object of type ContainingClass which has a public attribute childClassInstance of type ChildClass. ContainingClass is linked to a library component which does have a ChildClass instance as a child. Finally, note that ChildClass is in samplePackageB.a while ParentClass is in samplePackageA.

So the code looks like this:

    package samplePackageA
    {
        public class ParentClass extends MovieClip
        {
            protected var _parentValue:String;
            [Inspectable(defaultValue="")]
            public function get parentValue():String { return _parentValue; }
            public function set parentValue(value:String):void {
                _parentValue = value;
            }
            ...
        }
    }

    package samplePackageB.a
    {
        import samplePackageA.ParentClass;
        public class ChildClass extends ParentClass
        {
            [Inspectable(defaultValue="1.0")]
            public var childProperty:Number;
            ...
        }
    }

    package samplePackageB.b
    {
        import samplePackageB.a.ChildClass;
        public class ContainingClass extends MovieClip
        {
            public var childClassInstance:ChildClass;
            ...
        }
    }

I added ChildClass to the Component Definition of a library component. and I could read/set inspectable properties of both ParentClass and ChildClass in the Component Parameters of an instance of that library component which was on stage.

However, when I try to export a .swf of this .fla file, I get compiler error 1119, stating that I am "accessing (of) possibly undefined property childProperty through a reference with static type ParentClass".

The only similar issue I found can be viewed here but it seems it wasn't conclusively solved(or explained) then, either.

Aucun commentaire:

Enregistrer un commentaire