• Bugs
  • Starling null exception on simple code

Related Discussions
...

Hi,

long story short: I am even unable to get the example running.

I am currently using Starling 2.6.
Is there anything I might have missed? Like newer Starling SDK not being supported?

I double checked the loaded assets. They are correctly loaded and e.g. skeletonData correctly set.

I get hit with the following error; no matter the provided animation:

[App] Error: Error #1009: Cannot access a property or method of a null object reference.TypeError: Error #1009: Cannot access a property or method of a null object reference.
at spine.starling::SkeletonSprite/render()
at starling.display:😃isplayObjectContainer/render()
at starling.display:😃isplayObjectContainer/render()
at starling.core::Starling/render()
at starling.core::Starling/nextFrame()
at starling.core::Starling/onEnterFrame() TypeError: Error #1009: Cannot access a property or method of a null object reference.

My code:

         
[Embed(source = "./assets/animations/spineboy/spineboy-ess.json", mimeType = "application/octet-stream")] static public const SpineboyJson : Class; [Embed(source = "./assets/animations/spineboy/spineboy.atlas", mimeType = "application/octet-stream")] static public const SpineboyAtlas : Class; [Embed(source = "./assets/animations/spineboy/spineboy.png")] static public const SpineboyAtlasTexture : Class; var atlas : Atlas = new Atlas(new SpineboyAtlas(), new FlashTextureLoader(new SpineboyAtlasTexture())); var json : SkeletonJson = new SkeletonJson(new AtlasAttachmentLoader(atlas)); json.scale = 0.6; var skeletonData : SkeletonData = json.readSkeletonData(new SpineboyJson()); var stateData : AnimationStateData = new AnimationStateData(skeletonData); stateData.setMixByName("walk", "jump", 0.2); stateData.setMixByName("jump", "run", 0.4); stateData.setMixByName("jump", "jump", 0.2); var skeleton: SkeletonAnimation = new SkeletonAnimation(skeletonData, stateData); skeleton.x = 400; skeleton.y = 560; skeleton.state.addAnimationByName(0, "jump", false, 3); skeleton.state.addAnimationByName(0, "run", true, 0); addChild(skeleton);

Are you using the 4.0 Git branch? The example there runs for me, using VS Code (which is a bit tricky to setup).

What line in SkeletonSprite fails?

Yes, it's the latest (4.0) branch, just downloaded yesterday.
The example uses some outdated libs and SDK. I'm using Starling 2.6 (error also with 2.4) and AIR 33.1.476. I can't test AIR32 from the example, it's not even officially offered as download anymore.

I added the src instead of the swc to get some line:

Error: Error #1009: Cannot access a property or method of a null object reference.TypeError: Error #1009: Cannot access a property or method of a null object reference.
at spine.starling::SkeletonSprite/render()[/Users//www//Apps/libs/spine/spine-starling/src/spine/starling/SkeletonSprite.as:119]
at starling.display:😃isplayObjectContainer/render()[/Users/redge/Development/starling/starling/src/starling/display/DisplayObjectContainer.as:394]
at starling.display:😃isplayObjectContainer/render()[/Users/redge/Development/starling/starling/src/starling/display/DisplayObjectContainer.as:394]
at starling.core::Starling/render()[/Users/redge/Development/starling/starling/src/starling/core/Starling.as:460]
at starling.core::Starling/nextFrame()[/Users/redge/Development/starling/starling/src/starling/core/Starling.as:407]
at starling.core::Starling/onEnterFrame()[/Users/redge/Development/starling/starling/src/starling/core/Starling.as:635] TypeError: Error #1009: Cannot access a property or method of a null object reference.

I believe the issue lies with exporting the wrong format. It seems that PRO projects work, Essential do not. At least based on both spineboy examples (-as3 & -starling) and our own exports. *-starling (spineboy-pro) example I managed to get running.
Is that to be expected?
We are currently just testing it out for very basic stuff. Being forced to buy the pro version to simply test it out is kind of a steep investment and bad first impression.

Sorry for the bad first impression. We use Starling 2.4 in the example, as it is the lowest Starling version we officially support.

As for the Air SDK, we are using the latest version that Adobe officially supports, which is Air 32.0.0.116 (https://helpx.adobe.com/air/kb/archived-air-sdk-version.html). We aren't Air experts, so did not know that a third party called Harman has released a new version (https://airsdk.harman.com/download)

I've updated the example to Starling 2.6 and the Air SDK to 33.1.1.533, and the example project spine-starling-example works as intended, loading and rendering all skeletons successfully.

I then went on to replace the spineboy-pro.json asset used in SpineboyExample.as with the spineboy-ess.json file (https://github.com/EsotericSoftware/spine-runtimes/tree/4.0/examples/spineboy/export), and that too works as intended.

Then I went through your code, and saw you using FlashTextureLoader:

var atlas : Atlas = new Atlas(new SpineboyAtlas(), new FlashTextureLoader(new SpineboyAtlasTexture()));

And that is why your own code crashes. This texture loader is intended for the Flash runtime, not the Starling runtime. E.g. see our SpineboyExample.as code, where StarlingTextureLoader is used.

Also note that you do not have to purchase Spine to evaluate Spine Runtimes. We ship all our projects including exports in our spine-runtimes repo on GitHub (https://github.com/EsotericSoftware/spine-runtimes/tree/4.0/examples).