Export Minify Script Problem

0 favourites
  • 7 posts
  • 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!

  • Can you provide your .capx file?

  • 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.

         behinstProto.onCreate = function()
         {
            debugger;
            this.a_hash = {a: 10, b: 20};
            this.value = this.a_hash["a"];
            debugger;
         };

    after minify

    a.U=function(){debugger;this.Te={Gi:10,Hi:20};this.value=this.Te.a;debugger};

    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:

    this.a_hash = {a: 10, b: 20};

    minify

    this.Te={Gi:10,Hi:20};

    So that

    this.value=this.Te.a;

    will not get the correct value.

    I put the test code in

    dl.dropbox.com/u/5779181/test_minify.7z

    My C2 version is r63 64bits

  • 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.

  • It seems minify will change the name of properties in an object.

    Yes, this is how the minifier works, and it's talked about in the 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.

    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 <img src="smileys/smiley1.gif" border="0" align="middle">

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks, I work around by change

    this.a_hash = {a: 10, b: 20};

    to

    this.a_hash = {"a": 10, "b": 20};

    and it works.

  • 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?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)