How do I use file Chooser

Just started using Construct 2? Post your questions here

Post » Sat Jun 28, 2014 9:57 am

Hello,

I didn't quite understand the usage of file chooser. I added the plugin. I want to make a sprite load the chosen image file if it is it is an image, set textbox of a txt file if the chosen thing is a text file and display the url in a text. How do i do that?

Thanks,
Ashwin
B
15
S
3
G
1
Posts: 111
Reputation: 1,664

Post » Sat Jun 28, 2014 10:41 am

Ashwin try this demo
You do not have the required permissions to view the files attached to this post.
B
245
S
39
G
15
Posts: 1,946
Reputation: 40,266

Post » Sat Jun 28, 2014 11:13 am

not this one, the one scirra has provided in the latest version
B
15
S
3
G
1
Posts: 111
Reputation: 1,664

Post » Sat Jun 28, 2014 12:14 pm

After choosing a file, the file chooser plugin gives you a URL to the file (the FileURL expression). You can pass that to the Sprite's 'Load image from URL' action or make an AJAX request to it.
Scirra Founder
B
387
S
230
G
88
Posts: 24,251
Reputation: 192,454

Post » Sat Jun 28, 2014 2:03 pm

Here's a silly example based on what Ashley as said. Use the Filechooser to select an image, then try a text file. Hopefully all self-explanatory.
You do not have the required permissions to view the files attached to this post.
Last edited by zenox98 on Tue Jul 01, 2014 6:16 pm, edited 1 time in total.
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 » Sun Jun 29, 2014 10:42 am

I tried to replicate your demo @zenox98 but couldn't quite get it right. now when i add File chooser- on change --> Set textbox.text to Filechooser.FileType (Index). What should i add in the place of 'index'?
B
15
S
3
G
1
Posts: 111
Reputation: 1,664

Post » Sun Jun 29, 2014 10:45 am

For index, I used the number zero, based on the premise that, like arrays, it will be zero-based.

** Edit **

Just checked, and you if set Filechooser 'Select' property to 'Multiple', then choose more than one image, setting index to 1 does indeed select the second file.
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 Jul 03, 2014 11:22 am

even text boxes always come on top of the layer. @ashley - any help ?
B
15
S
3
G
1
Posts: 111
Reputation: 1,664

Post » Thu Jul 03, 2014 12:04 pm

All form controls float above the canvas. That can't be changed.
Scirra Founder
B
387
S
230
G
88
Posts: 24,251
Reputation: 192,454

Next

Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 3 guests