Plugin developers: please test with the minifier

For developers using the Construct 2 Javascript SDK

Post » Wed Dec 21, 2011 3:50 am

@rexrainbow, the minifier doesn't support non-minify sections. Besides, as long as you write the code properly to the conditions the minifier requires, it does not change the functionality at all.
Scirra Founder
B
359
S
214
G
72
Posts: 22,951
Reputation: 178,578

Post » Thu Dec 22, 2011 12:54 am

Thanks for the feedback, I'll push out a fix with it. Strange it never changed playtomic in all my testing, now that you mention it.

Just curious, is the performance of [""] the same as directly referencing? I was under the general impression that looking up an object according to a string is a little slower than accessing it directly. But maybe it's different in js?
B
22
S
9
G
5
Posts: 122
Reputation: 5,386

Post » Thu Dec 22, 2011 1:05 am

[""] is actually translated to . by the minifier, so it doesn't have any performance impact. In other words object.mySuperProperty will be minified to something like m.pX, but object["mySuperProperty"] will be minified to m.mySuperProperty (so it keeps the name but changes the syntax).

I just realised if 'Playtomic' is defined by an external script, you don't need to do what I said, because it's defined in another script that is not minified :)
Scirra Founder
B
359
S
214
G
72
Posts: 22,951
Reputation: 178,578

Post » Thu Dec 22, 2011 1:54 am

Super, thanks!
B
22
S
9
G
5
Posts: 122
Reputation: 5,386

Post » Mon Nov 10, 2014 9:24 am

I am having issues in reading objects local variable in plugins.
even without the minifier, parsing a variable name in plugin to fetch the value is not working.
is the exporter braking it? because it is working fine in browser.
B
7
S
1
Posts: 26
Reputation: 530

Post » Mon Nov 10, 2014 9:51 am

@hassiba

I though global/local/private variables are stored in an array structure in engine.
B
97
S
22
G
178
Posts: 4,118
Reputation: 104,043

Post » Mon Nov 10, 2014 10:26 am

@rexrainbow
may be i used the wrong term in describing the problem.

what I meant is the assigned variable to a sprite object. this is what I am trying to read in my behavior
yes, they are stored in two arrays, one for variable names, and one for variable value.

like this:
Code: Select all
 var retvar;
         for(var instVarNameIndex in instVarNames)
         {
            if(instVarNames[instVarNameIndex] == varStr) // <== this does not seem to find a match in XDK emulator, but works in browser
            {
               varIndex = instVarNameIndex;
               retvar = inst_only.instance_vars[varIndex];
               
            }
         }
B
7
S
1
Posts: 26
Reputation: 530

Post » Mon Nov 10, 2014 2:57 pm

@hassiba - if it doesn't work with the minifier disabled then it's nothing to do with the minifier! You should debug the code to find out what's going on.
Scirra Founder
B
359
S
214
G
72
Posts: 22,951
Reputation: 178,578

Post » Mon Nov 10, 2014 5:45 pm

@hassiba Are you looping over properties in an object or over an array? I assume you have read this https://developer.mozilla.org/en-US/doc ... s/for...in?
B
18
S
7
Posts: 88
Reputation: 1,424

Post » Tue Nov 11, 2014 10:45 am

@Arne
These are instance variables in an object.
I did debug the issue as Ashly suggested. and I have noticed the following:
in Intel XDK emulator, the instance variable name lookup to get the index number fails. while it works perfectly fine in browser.

those instance variables are zero indexed by the same order when first created in C2. hence if I access them by index number I have no issue, even in XDK.
B
7
S
1
Posts: 26
Reputation: 530

PreviousNext

Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 0 guests