1
votes

I've got the Error 1119 and I can't understand why. It drives me crazy !

I've got a movieclip named "useBox" which is called in my Engine.as

package com.laserdragonuniversity.alpaca {
    public class Engine extends MovieClip{
            public static var toolbar:Toolbar;
            public static var useBox:UseBox;

    public function Engine(){

    private function configLoaded(e:Event):void{
    useBox = new UseBox(stage, usableItems[0]);

    private function examine(e:MouseEvent):void{
                    stage.dispatchEvent(new Event("itemClicked"));
                        useBox = new UseBox(stage, e.currentTarget);
                        useBox.x = mouseX;
                        useBox.y = mouseY;
                        stage.addChild(useBox);
                    }

I've got a UseBox class :

UseBox.as :

package com.laserdragonuniversity.alpaca {
public class UseBox extends MovieClip{
public function UseBox(stageRef:Stage, thisThing:Object){
            this.stageRef = stageRef;
            this.thisThing = thisThing;
            toolbar = Engine.toolbar;
            batiments = Engine.batiments;

            this.visible = true;
            useButton.visible = false;
            useButton2.visible = false;
}

And in a Puzzle.as class, I'm trying to make useButton visible.

package com.laserdragonuniversity.alpaca {
public class Puzzle extends MovieClip{
private var toolbar:Toolbar;
        private var useBox:UseBox;

public function Puzzle(stageRef:Stage){
            useBox = Engine.UseBox;

public function clickEmplacement2(event:MouseEvent):void {
useBox.useButton2.visible = true;
}

But I've got the error 1119 : Access of possibly undefined property UseBox through a reference with static type Class. (for the line "useBox = Engine.UseBox;")

Do you know why ?

1
Why are Engine’s properties static? They shouldn’t be. - poke
Your Puzzle class does not know if Engine.UseBox has already been initialized or not. Since Engine config is loaded asynchronously, it is highly probable that Puzzle instance loads before Engine's configLoaded function. - axelduch

1 Answers

0
votes

It looks like your issue is that Engine.UseBox; is uppercase, so the code thinks your talking about the class UseBox, rather than the instance Engine.useBox;