COMMUNITY

What is "Error:(12, -1) Defined in this class" referring to?


(Chrisvelevitch) #1

I’m getting this error:-

Error:(12, -1) Defined in this class

and the full code is:-

import feathers.system.DeviceCapabilities;
import openfl.display.MovieClip;
import openfl.display.StageAlign;
import openfl.display.StageScaleMode;
import openfl.events.Event;
import openfl.geom.Rectangle;
//import openfl.ui.ContextMenu;
import starling.core.Starling;

@:meta(SWF(width="960",height="640",frameRate="60",backgroundColor="#4a4137"))

class HelloWorldWeb extends MovieClip
{
    public function new()
    {
        super();
//        var menu : ContextMenu = new ContextMenu();
//        menu.hideBuiltInItems();
//        this.contextMenu = menu;
        
        if (this._starling.stage != null)
        {
            this.stage.align = StageAlign.TOP_LEFT;
            this.stage.scaleMode = StageScaleMode.NO_SCALE;
        }
        
        this.loaderInfo.addEventListener(Event.COMPLETE, loaderInfo_completeHandler);
    }
    
    private var _starling : Starling;
    
    private function start() : Void
    {
        this.gotoAndStop(2);
        this.graphics.clear();
        
        //simulating iPhone Retina
        DeviceCapabilities.dpi = 326;
        
        Starling.multitouchEnabled = true;
//        var MainType : Class<Dynamic> = Type.getClass(Type.resolveClass("feathers.examples.helloWorld.Main"));
        var MainType : Class<Dynamic> = feathers.examples.helloWorld.Main;
        this._starling = new Starling(MainType, this.stage, new Rectangle(0, 0, 960, 640));
        this._starling.supportHighResolutions = true;
        this._starling.skipUnchangedFrames = true;
        this._starling.stage.stageWidth = 480;
        this._starling.stage.stageHeight = 320;
        this._starling.start();
    }
    
    private function loaderInfo_completeHandler(event : Event) : Void
    {
        this.start();
    }
}

Line 12 is:-

class HelloWorldWeb extends MovieClip

What is the compiler complaining about?

I’m compiling with openFl and targeting HTML5.


(Jens Fischer) #2

“Defined in this class” is not really an error itself, it’s just additional position information for another error. So you should have more errors than just that.


(Chrisvelevitch) #3

No, that’s the only error for this class.


(Jens Fischer) #4

For this class perhaps, but there must be another error that the “defined in this class” belongs to. :slight_smile: Here’s an example:

class Main {
	public static function main() {
		trace(Foo);
	}
}
class Foo extends Bar {}

Produces the following error:

source/Foo.hx:1: characters 19-22 : Type not found : Bar
source/Main.hx:1: lines 1-5 : Defined in this class

“Defined in this class” should always be directly after the error it belongs to, at least on the command line. In IDEs, errors might get reordered, making it a bit more confusing.