Create a File Browser
In AutoPlay Media Studio it is possible to have a list of files that the user can click on to open.
As an example, we will create a listbox with two movie choices in it. The user will click on one of the files, and click a button to open the file.
Note: If you have enabled the Multiple Selection option for your listbox, the example above will only open the first file selected.
Tip: You may wish to add some logic to prevent errors from occurring. One such error is if the user clicks in the listbox but selects nothing. The script above would still fire, but line 2 would fail because selected[1] would be nil. You can use an if statement to check for nil values:
if (selected) then
-- There is at least one item selected, put your actions here
end
That way, nothing occurs unless something is selected (nil related errors are prevented).
In AutoPlay Media Studio it is possible to have a list of files that the user can click on to open.
As an example, we will create a listbox with two movie choices in it. The user will click on one of the files, and click a button to open the file.
- Create a listbox object.
- Add the movie names as the item text and the path to the movies as the item data.
- Create a button.
- In the On Click event of the button's script tab, add the following script:
Kod:
selected = ListBox.GetSelected("ListBox1");
file = ListBox.GetItemData("ListBox1", selected[1]);
File.Open(file, "", SW_SHOWNORMAL)
Note: If you have enabled the Multiple Selection option for your listbox, the example above will only open the first file selected.
Tip: You may wish to add some logic to prevent errors from occurring. One such error is if the user clicks in the listbox but selects nothing. The script above would still fire, but line 2 would fail because selected[1] would be nil. You can use an if statement to check for nil values:
if (selected) then
-- There is at least one item selected, put your actions here
end
That way, nothing occurs unless something is selected (nil related errors are prevented).