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

Get help using Construct 2

Post » Tue Jan 06, 2015 1:56 pm

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:
Untitled.png

If I pick a different file and then the original again it works, but not directly one after another.
You do not have the required permissions to view the files attached to this post.
B
19
S
6
G
6
Posts: 1,101
Reputation: 5,646

Post » Thu Jan 08, 2015 8:46 am

A mild bump as this is still an issue...
B
19
S
6
G
6
Posts: 1,101
Reputation: 5,646

Post » Thu Jan 08, 2015 8:58 am

Shouldn't that be, from For "" from 0 to Array.Height - 1?
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Thu Jan 08, 2015 9:05 am

That I have already fixed, but the original problem remains - you can only load the given file once in a row.
B
19
S
6
G
6
Posts: 1,101
Reputation: 5,646

Post » Thu Jan 08, 2015 9:17 am

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).
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
52
S
22
G
18
Posts: 2,122
Reputation: 17,093

Post » Thu Jan 08, 2015 9:46 am

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):
Untitled.png


So does it sound like a bug? I might try making a mini-capx and submit it.
You do not have the required permissions to view the files attached to this post.
B
19
S
6
G
6
Posts: 1,101
Reputation: 5,646

Post » Thu Jan 08, 2015 9:58 am

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 :)
If your vision so exceeds your ability, then look to something closer.
Moderator
B
131
S
29
G
81
Posts: 5,328
Reputation: 56,630

Post » Thu Jan 08, 2015 10:24 am

Here we go:
FileChooserProblem.capx


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?
You do not have the required permissions to view the files attached to this post.
B
19
S
6
G
6
Posts: 1,101
Reputation: 5,646

Post » Thu Jan 08, 2015 4:30 pm

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.
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
52
S
22
G
18
Posts: 2,122
Reputation: 17,093

Post » Thu Jan 08, 2015 4:51 pm

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.
You do not have the required permissions to view the files attached to this post.
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,620

Next

Return to How do I....?

Who is online

Users browsing this forum: jaytrott86 and 8 guests