Very strange bug with preview vs export

0 favourites
  • 8 posts
From the Asset Store
Strange factory themed set of tiles for your platformer game
  • Ashley

    I'm running into a big problem where exporting seems to change functionality from preview completely. Lots of things which run fine in preview are spontaneously broken during export. I'm getting a very weird bug where actions work fine in preview and cause errors with "func.apply" in Action.run_object, saying func is undefined. I'm really baffled as to why the export (so far NW and HTML5) are behaving SO differently than the preview, that actions aren't even being called.

  • Is this affecting your own plugin? Are you sure the code works with the minifier?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Code doesn't work with the minifier, but i'm not running the minifier so i'd expect behaviour to be identical to preview. It's my own plugin yes.

    As an example I have specific functions in Acts.prototype, like, and .

    to test i made an event in a blank project with my plugin like "on key z pressed : alert something" and that causes the following js code to execute:



    in preview:

    the first alert returns the contents of a function as expected.

    the second alert returns the contents of a function as expected.

    in export:

    the first alert returns the contents of a function as expected.

    the second alert returns undefined.

    if i attempt to run the action which returns undefined in my project, i get the "cannot call .apply on undefined" bug

    The fact that some of my actions just don't exist on export is very confusing, and I can't figure out why this is happening on export only, unless C2 is parsing things completely different than in preview.

  • I also just recently had to fix a new problem where my code wasn't working anymore in export because i had comments on a single line using /*comment*/. i'm just guessing that it had something to do with the /**PREVIEWONLY**/ style compiler instructions.

    I'm not sure how i'm supposed to debug when its specifically exports causing me trouble, and everything works fine in preview. I wouldn't expect anything to change so vastly

  • I've made a simple routine to check which functions are being added to Act.prototype

    var str = ""

    var key

    for( key in Acts.prototype) str += key+"\n"


    when i call this, in preview all my actions appear, but in export a big block of them are mysteriously gone, but not all of them.

  • So far what i understand a little more from more testing.

    I have a lot of actions (about 150). From the previous for-in loop i found that there was a chunk of maybe about 30+ actions that come up sequentially in the runtime.js file of my plugin but are missing from the prototype in export. there are actions which aren't missing which come before and after this chunk. My theory is that the 'compiler' - parser- whatever you might call it, which runs during export, is clipping out a big chunk of code from the runtime for some strange reason which i'm not sure of.

    I added alerts throughout my code so that i have my runtime.js file set up something like this:

    .................... above this point there are lots of actions that weren't missing around where actions started to go missing from acts.proto on export i added alerts.


    Acts.prototype.function001 = function(p1,p2,p3){




    Acts.prototype.function001 = function(p1,p2,p3){




    Acts.prototype.function002 = function(p1,p2,p3){




    Acts.prototype.function003 = function(p1,p2,p3){




    .................. more actions which didn't go missing.

    running the project, in preview all the alerts fire as you would expect, but on export only those which come after a certain point, and those which come before a certain point, are firing. theres a block of script which just disappears for no good reason. I've poured over the code and there doesn't "seem" to be anything suspicious which should cause this, but it's happening anyway.

  • I've no idea either. I don't think I can help without a code example.

  • I managed to fix the problem by deleting a multi line comment from within a function...

    i had something like:


    Act.prototype.function001 = function(){

    var do,code;


    code = stuff();

    /* bla bla bla


    bla bla

    this is actually a multiline comment*/



    ...... etc.

    if i delete the multi-line comment from within the function, everything works as intended...

    There something very wrong with how multi-lines are being handled by the exporter. I think its pretty agreeable that deleting a comment is a very obscure bug-fix. I almost don't believe it's that but after testing quite a bit im 100% sure.

    I can send you stuff if you want to investigate but it'll have to be privately.

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