Javascript Plugin private methods

For developers using the Construct 2 Javascript SDK

Post » Thu Jun 20, 2013 10:02 pm

Hi

Im exploring the plugins SDK, and have hit a roadblock.

I managed to get my plugin running. Ive managed to create new Actions; like this one:



Acts.prototype.DoSomething = function (text_value, X, Y)
     {
          var i,j;
          for (i=1; i < X; i++)
          {
               for (j=1; j < Y; j++)
               {
                   testFunction(i,j);
               }
          }
     };
     

But I cant figure out how to do functons. In this example, testfucntion (i,j).

I made it like this:


     this.testFunction = function (x,y)
     {
          //do stuff
     };


But it doesnt work. How can I white a function,or aprivate method, or some code that the Acts.prototype.DoSomething can use?

Thanks.
B
7
S
3
G
3
Posts: 53
Reputation: 2,459

Post » Fri Jun 21, 2013 12:43 am

Apparently, I had to declare the function like this:

instanceProto.testFunction = function (x,y)
     {
          //do stuff
     };
B
7
S
3
G
3
Posts: 53
Reputation: 2,459


Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 0 guests