Skip to main content
Participating Frequently
November 7, 2024
Answered

Uncaught ReferenceError: lib is not defined

  • November 7, 2024
  • 1 reply
  • 478 views

Hi!

From my Animate Canvas file I am calling a game-scripts.js file with the following code:

 

function iniciar(){
	var pincel = new lib.pincel();
	this.addChild(pincel);
}

 

When I publish my html file, the console gives me this error:

 

Uncaught ReferenceError: lib is not defined
at iniciar (script-juegos.js:3:15)
at lib.princesa01.frame_0 (princesa01.js?1730987426814:3682:3)
at d._runActionsRange (createjs.min.js:19:7215)
at b._runActions (createjs.min.js:19:3229)
at b._runActionsRange (createjs.min.js:19:10055)
at b._runActions (createjs.min.js:19:3229)
at b.setPosition (createjs.min.js:19:1519)
at c._updateTimeline (createjs.min.js:14:29260)
at c.advance (createjs.min.js:14:28504)
at c._tick (createjs.min.js:14:28796)

 

Apparently lib is not defined. Could someone help me define lib? 

Thanks!

    This topic has been closed for replies.
    Correct answer JoãoCésar17023019

    Hi.

     

    Is the iniciar function defined within game-scripts.js? If so, you should pass the lib object as an argument to an iniciar function call in the main timeline. Like this:

    // main timeline
    iniciar(lib);
    
    // game-scripts.js
    function iniciar(lib)
    {
     // ...
    }

     

    Regards,

    JC

    1 reply

    JoãoCésar17023019
    Community Expert
    JoãoCésar17023019Community ExpertCorrect answer
    Community Expert
    November 7, 2024

    Hi.

     

    Is the iniciar function defined within game-scripts.js? If so, you should pass the lib object as an argument to an iniciar function call in the main timeline. Like this:

    // main timeline
    iniciar(lib);
    
    // game-scripts.js
    function iniciar(lib)
    {
     // ...
    }

     

    Regards,

    JC

    Participating Frequently
    November 7, 2024

    Solved. Thank you!

    JoãoCésar17023019
    Community Expert
    Community Expert
    November 7, 2024

    You're welcome!