Uncaught exception - Invalid field access : objects



  • Hi! I'm new to Haxe and HaxeFlixel, so everything is not clear for me.
    So, currently I am following the game tutorial on the Docs page. I finished doing the part 6 - Loading the Tilemap, and when I run lime test neko, it opens the game but when I click the start button, the game crashes and the console shows the following errors:

    Called from ? line 1
    Called from ApplicationMain.hx line 25
    Called from ApplicationMain.hx line 130
    Called from lime/app/Application.hx line 150
    Called from lime/_internal/backend/native/NativeApplication.hx line 146
    Called from a C function
    Called from lime/_internal/backend/native/NativeApplication.hx line 370
    Called from lime/_internal/macros/EventMacro.hx line 91
    Called from openfl/display/Stage.hx line 1890
    Called from openfl/display/Stage.hx line 1174
    Called from openfl/display/Stage.hx line 1440
    Called from openfl/display/Stage.hx line 1170
    Called from openfl/display/DisplayObject.hx line 1418
    Called from a C function
    Called from openfl/events/EventDispatcher.hx line 402
    Called from flixel/FlxGame.hx line 545
    Called from flixel/FlxGame.hx line 677
    Called from flixel/FlxGame.hx line 724
    Called from flixel/FlxGame.hx line 637
    Called from PlayState.hx line 32
    Uncaught exception - Invalid field access : objects

    In PlayState.hx, at line 32 is the following code:
    for (e in tmpMap.objects)
    {
    placeEntities(e.name, e.xmlData.x);
    }

    Can someone help?

    I'm on Linux, using VSCode.
    haxelib list returns
    actuate: [1.8.9]
    box2d: [1.2.3]
    flixel-addons: [2.7.5]
    flixel-demos: [2.7.1]
    flixel-templates: [2.6.3]
    flixel-tools: [1.4.4]
    flixel-ui: [2.3.2]
    flixel: [4.6.3]
    hscript: [2.3.0]
    hxcpp: [4.0.64]
    layout: [1.2.1]
    lime-samples: [7.0.0]
    lime: [7.6.3]
    openfl-samples: [8.7.0]
    openfl: [8.9.5]
    systools: [1.1.0]



  • You might have a mistake in your code somewhere. The tutorial shows 2 options for loading the tilemap. Make sure to use the correct code depending whether you use Ogmo or Tiled to create your tilemap.

    or, there could be a mistake in your created tilemap? The map data room-001.oel for the demo is here



  • @dean Yeah, I had mistyped the layer name. Now, I got a new error. It is the same but the last line is Uncaught exception - Invalid field access : length

    Any ideas?



  • @xnpxgames

    That tutorial causes confusion because it includes two ways to create the map. If you're using FlxOgmoLoader map then you don't need that loop.

    From tutorial section 6:

    TiledMap does not have a built-in loadEntities() function, so for that you'll need to change this to:

    for (e in tmpMap.objects)
    {
        placeEntities(e.name, e.xmlData.x);
    }
    

    But unless you're using FlxTileMap to create the map you dont need that.
    If you're using FlxOgmoLoader , make sure to ignore the change this to ... for Tiled parts.

    There's a link to the completed project on the Conclusion page of the tutorial where you can check the code.


Log in to reply
 

Looks like your connection to HaxeFlixel was lost, please wait while we try to reconnect.