Export Minify Script Problem

Bugs will be moved here once resolved.

Post » Mon Oct 10, 2011 6:11 pm

Hello guys.
I export my project and discovered a problem.
Every time I use the option of the exporter "Minify Script (recommended)"
Some things in my project, stop working.

The application opens normally. More after this open, I think that the events "Every tick" or events that are executed after the "Start of Layout" some stop working!

When I do not use the option "minify script" in construct 2!
I export my project, and it works perfectly!
I minify my script manually with "YUI Compressor" of Yahoo!
And also my projetct worked perfectly!

I believe there is a problem in the script construct minify!
Regards!

B
2
G
4
Posts: 10
Reputation: 1,070

Post » Mon Oct 10, 2011 7:06 pm

Can you provide your .capx file?
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,630

Post » Mon Oct 24, 2011 1:16 am

It seems minify will change the name of properties in an object. If this object is a hash and fetched by a key string. It may become an error.

For example, create a plugin with this code.
[code]     behinstProto.onCreate = function()
     {
        debugger;
        this.a_hash = {a: 10, b: 20};
        this.value = this.a_hash["a"];
        debugger;
     };[/code]

after minify
[code]a.U=function(){debugger;this.Te={Gi:10,Hi:20};this.value=this.Te.a;debugger};[/code]

The goal of origin script is to get data by key "a" from a hash. But minify changes the name of key in the hash.

origin:
[code]this.a_hash = {a: 10, b: 20};[/code]
minify
[code]this.Te={Gi:10,Hi:20};[/code]

So that
[code]this.value=this.Te.a;[/code]
will not get the correct value.

I put the test code in
http://dl.dropbox.com/u/5779181/test_minify.7z

My C2 version is r63 64bitsrexrainbow2011-10-24 01:27:16
B
97
S
22
G
179
Posts: 4,124
Reputation: 104,555

Post » Mon Oct 24, 2011 1:34 am

same to me, i did a project with older versions (r55), and with r63 the exported folder is not working anymore in any browser, uploaded.

but its not only minified exported projects by me, i've been trying both versions. firefox and opera just dont load the games, without any error. the layout stays white.
B
15
S
3
G
5
Posts: 396
Reputation: 4,977

Post » Mon Oct 24, 2011 1:43 am

[QUOTE=rexrainbow] It seems minify will change the name of properties in an object.[/QUOTE]
Yes, this is how the minifier works, and it's talked about in the SDK documentation.

[quote="SDK documentation"]When exporting, Construct 2 gives the user the option to 'Minify script'. This runs the common and runtime scripts through Google Closure Compiler's ADVANCED_OPTIMIZATIONS mode. This imposes some limitations on what scripts can do. You must obey these limitations when writing your plugins, otherwise your plugin will be broken on export. More details can be found here (http://code.google.com/closure/compiler/docs/api-tutorial3.html).

The main thing is to always use dot syntax (Object.property) rather than bracket syntax (Object["property"]). All properties using dot syntax are changed by Closure Compiler, but none of the properties in bracket syntax are changed. Therefore, if you use Object.property in one place and Object["property"] in another to access the same property, the plugin will be broken on export. You may still use bracket syntax (e.g. for a dictionary of user-inputted strings) - just be aware of how Closure Compiler will transform the code.

Remember the edittime scripts are not passed through Google Closure Compiler, so you can write them how you like.[/quote]

If code like you pointed out occurs in official plugins, behaviors or scripts please do file a bug report. However, if it's in third party plugins or behaviors you should tell the developer about it, not us... and then tell them off for not reading the documentation and writing a broken plugin
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,630

Post » Mon Oct 24, 2011 3:21 am

Thanks, I work around by change
[code]this.a_hash = {a: 10, b: 20};[/code]
to
[code]this.a_hash = {"a": 10, "b": 20};[/code]
and it works.
B
97
S
22
G
179
Posts: 4,124
Reputation: 104,555

Post » Fri Nov 28, 2014 5:33 pm

I think i have some problem... After i export the my game to android..., Owh, before that, i make the game something like 'brick breaker' which is when the ball collision with block, got the point 50 and when the paddle laser is transform, laser is also provide point 50 when collision with block... but when i try to running that game at emulator on XDK after export that game, it have some problem which is ball collision with block got 50 point (this is true) but when laser is collision with block, the point is double which is 100 point... I dont know how that problem can occur... I already try to make or block and is also the same result... When i run my game at construct 2 'run layout'... There is no problem which is ball collision with block got 50 point and also laser collision with block got 50 point too... The problem is occur only at emulator on XDK... Please help me because i want to settle my 'Application Development' subject which is i develop a game call 'Fruit Breaker'... Is there any problem on that .js file query after i export it?
B
3
Posts: 1
Reputation: 177


Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 2 guests