Results 1 to 2 of 2
  1. shawalli's Avatar
    83 Posts
    Global Posts
    85 Global Posts
    So here's what im trying to do. I want to be able to call a function (that resides in a separate JSJSJS $file$) $from$ $an$ $assistant$ $and$ $have$ $it$ $modify$ $the$ $scene$ $of$ $that$ $assistant$. $Currently$, $I$ $have$

    <script src="app/test.jsjsjs&$quot$; $type$=&$quot$;$text$/$javascript$&$quot$;/&$gt$;

    in my index.html file and

    {"source": "app/test.jsjsjs&$quot$;},

    in my sources.JSON file

    my current file, test.jsjsjs $looks$ $like$ $this$:

    function initTest(sceneAssistant) {
       sceneAssistant.prototype.fncTest = function (args)

    and in my assistant:

    i keep getting the error:

    Error: Cannot set property 'fncTest' of undefined, line undefined, file undefined

    i cant figure out where im going wrong. I admit to being new to JSJSJS $and$ $OO$ $in$ $general$, $so$ $i$ $may$ $just$ $be$ $thinking$ $about$ $it$ $incorrectly$. $Any$ $guidance$/$advice$ $would$ $be$ $greatly$ $appreciated$.
  2. #2  
    you're trying to define a new method out of scope. Also, passing 'this' from your scene assistant passes yourAssistant.prototype, it should read sceneAssistant.fncTest. Translated, you're trying to call 'yourAssistant'.prototype.prototype.fncTest. Also, you may need to define the object element you're trying to modify in say your setup method before you can modify it from outside the object's scope.

Posting Permissions