[SOLVED] How i do to dynamically load animation files from a remote server?

I want to load a animation file from server in my script follow.js.

Follow.prototype.initialize = function() {

    this.app.assets.loadFromUrl("https://www.example.com/animacoes/animation.json", "animation", function (err, asset) {
        entity.addComponent("animation", {
            assets: [ asset ],
            speed: 1
    this.entity.animation.play(asset, 1.0);

But its error appear:

ReferenceError: entity is not defined

Can someone help me?
Best regards

this - in a callback is not same as this before the definition of a callback. This is “scoping” issue you are having here.

Please format your code for better readability.

Correct solution:

var self = this;
...loadFromUrl(..., function(err, asset) {
1 Like

it worked, thank you!