Why does this only work once? (FileChooser, AJAX and Array)

0 favourites
  • 14 posts
From the Asset Store
Change the size and position of everything without calculating anything!
  • Hi, all. I have a File chooser object which lets me load a local file using AJAX and pass that onto an array which then gets parsed.

    But why does this only work once per a given file? (In my case it's possible to load the file, and then load it again to generate a copy of the same object, for example:

    [attachment=0:3umk26uh][/attachment:3umk26uh]

    If I pick a different file and then the original again it works, but not directly one after another.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • A mild bump as this is still an issue...

  • Shouldn't that be, from For "" from 0 to Array.Height - 1?

  • That I have already fixed, but the original problem remains - you can only load the given file once in a row.

  • kind of weird, my guess would be that C2 see that it is the same file and so do not load it again (even though it has been released) which makes the ajax request not complete (does the ajax on error trigger?), which would be worthy of a bug report (that is, if I am right).

  • I just added a check - no error is triggered. I can still load another file just fine, but not the same file twice.

    Any file load operation seems to reset it so the 2nd go is a-ok. I'm attaching the current events, so my stupid mistakes don't distract from this problem (although even clearing on every iteration should have loaded at least one entry):

    [attachment=0:33f0hg6z][/attachment:33f0hg6z]

    So does it sound like a bug? I might try making a mini-capx and submit it.

  • Creating a small .capx is a good idea regardless as others can then test and may be able to either confirm as a bug - in which case you can post in Bugs section - or possible see an error in the events or logic. Win win all round

  • Here we go:

    [attachment=0:4ebiks4s][/attachment:4ebiks4s]

    Save the locations to file, clear the area, load file - first time it works, clear area, try to load again - no luck.

    Actually I think the name of the action - "On change" kinda hints at this, since with the same file there's no change? But that doesn't sound like the expected behaviour.

    Can someone confirm this and check if the events themselves are correct?

  • I cannot test now (not on a computer), but

    "On changed

    Triggered when a file or set of files has been chosen from the input control." (from the manual)

    so the expected behavior is that it triggers even if you choose the same file again.

  • Yeah the "on change" doesn't fire when you select the same file. In Chrome at least. It works in Firefox.

    As a workaround you can clear the selected file with some JavaScript.

  • Will try as I'm back at the Pc.

    Worthy of a big report or Just a chrome quirk then?

  • Might prove useful to add a built-in "clear" to reset the control value without using javascript directly.

  • Thank you, ramones, confirmed as working in my full system as well. Let's ping Ashley in case he'd like to fix this for Chrome.

  • Please file a bug report following all the guidelines if you want me to investigate.

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