Indigo Rose Software
  #1  
Old 11-01-2007
Adam's Avatar
Adam Adam is offline
Indigo Rose Staff Member
 
Join Date: May 2000
Location: Indigo Rose Software
Posts: 2,154
ListBox indexing explained

Question
How do I access data stored in a ListBox?

Answer
A ListBox is a great way to store data that a user can select at runtime to perform a function. For this example we will make a ListBox that stores files and then opens them when the user double clicks on one of the entries.

Create a ListBox object on the relevant page of your AutoPlay Media Studio project. For each entry in the ListBox have your data setup like this:

Item Text:
DocumentName

Item Data:
AutoPlay\\Docs\\mydocument.pdf

Now go to the Script tab and navigate to the 'On Double-Click' event.

The first action needed is ListBox.GetSelected(). This action returns a table containing all of the selected indexes of the ListBox. Since most document lists do not allow multiple selection we can make some assumptions about the returned data. Your action could look like this:

index = ListBox.GetSelected("ListBox1");

In this case we know that the selected index is stored in index[1]

The next step is to get the data that is associated with the selected index. The action ListBox.GetItemData(). This action will return the data associated with the selected item in the ListBox. We will need the selected index from the step above to get the data.

data = ListBox.GetItemData("ListBox1", index[1]);

Now the variable data contains the path to the selected document.

The next action is to open the document using a File.Open() action. The action will look like this

File.Open(data, "", SW_SHOWNORMAL);

The final script with comments will look like this

-- Get the selected index
index = ListBox.GetSelected("ListBox1");
-- Get the data associated with the selected item
data = ListBox.GetItemData("ListBox1", index[1]);
-- Open the document
File.Open(data, "", SW_SHOWNORMAL);
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Listbox disappearing question ebrusher AutoPlay Media Studio 5.0 3 07-09-2005 07:38 AM
Example: Using the ListBox object Ted Sullivan AutoPlay Media Studio 5.0 Examples 0 05-07-2004 01:24 PM
Listbox... how to? part 2 cold_fusion AutoPlay Media Studio 4.0 7 02-07-2004 01:28 PM
Listbox indexing problem... Martin_SBT AutoPlay Media Studio 5.0 6 01-28-2004 09:43 AM
From listbox to listbox to flash Konradsen AutoPlay Media Studio 4.0 5 05-13-2003 07:24 AM


All times are GMT -6. The time now is 11:10 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright © 2000 - 2009 Indigo Rose Corporation. All rights reserved.
Indigo Rose Software