ListItems

Manages a list of text items, loaded from a text file, and delivers each item in order or randomly

The ListItems widget loads a list from a text file. When requested, the widget will deliver the next item in the list, sorted in a variety of ways. This widget can be accessed via other widgets that support it (currently VideoControl and SoundControl), or by ActionScript through a simple function call (see bottom of this page).

To use ListItems, create a text file in the same directory as the Flash file you are creating, with each item in the list separated by a comma (the default, can be changed in the delimiter parameter). For example, you might create a file called “list.txt” and put the following in it:

myvideo1.flv,myvideo2.flv,myvideo3.flv,myvideo4.flv

After placing the ListItems widget on the Flash stage, use the Component Inspector to set the name of the file that contains the list, and select the type of order you want each item delivered in (see below for details. Then give the widget an instance name.

If you want to use this list with VideoControl or SoundControl, select the widget and using the Component Inspector to set the “listItemName” parameter to the instance name of the ListItems widget. For VideoControl, first follow the directions in the VideoControl documentation and create a new video object in the library and place it on the stage. Then set the videoProperty to “playPause” and playPauseBehavior to “restart”. For SoundControl, set soundBehavior to one of the “restart” settings. The VideoControl and SoundControl widgets will only access the ListItems widget with the parameters set this way, otherwise they will use specified filename in the widget. Now, each time VideoControl or SoundControl starts playing video or audio, it will get the next filename to play from ListItems.

On Screen Features

  • ORDER: The list order you’ve selected
  • NEXT: The item name (and numeric order) that will be delivered the next time ListItems is requested to give one
  • ITEM: The most recent item name (and numeric order) that was delivered last

Parameters

  • DELIMITER: Sets the text used to separate each item. By default it is a comma “,” but any character string can be used. If you want your items to be separated in the file by a line break, on the Mac use “\n”, and on Windows use “\r\n” to represent the LF (line feed) or CRLF (carriage return/line feed) respectively.
  • INVISIBLE: If set to “true” or checked, the widget will disappear when the Flash movie is run – NOTE: you can make all the widgets invisible interactively when the Flash moving is running by pressing the backslash key “\”.
  • LISTFILENAME: The name of the file that contains the original list. Each item in the list should be separated by a comma “,” or whatever the DELIMITER text is. E.g. myvideo1.flv,myvideo2.flv,myvideo3.flv,myvideo4.flv
  • LISTORDER: Sets the order of how the items in the list will be delivered:
    • ordered: in the order they are in the original file
    • ordered_reverse: in the reverse order they are in the original file
    • random: in true random order, which means that any of the items can be delivered each time, including possible repeats
    • random_norepeat: the same as “random” but no item will ever be delivered twice in a row
    • random_full_list: takes the entire list and puts it in random order. the entire list is delivered with no repeats. Once the random list is exhausted, a new full random order is generated, where the new list does not repeat the last item in the previous order.

ActionScript Functions

If you want to access the ListItems with ActionScript, there are several functions available. The sample code for these functions assumes a ListItems widget that has an instance name of “myListItems”. Note: the ListItems widget does NOT require the Hub to be running, so you can use this widget in any Flash application.

nextItem()

Returns the next item in the list (as determined by the “LIST ORDER” parameter)

var theNextItem:String;
theNextItem = myListItems.nextItem();
trace(theNextItem);

item(itemIndex:int)

Returns the item in the original list at the itemIndex specified.

var theItem:String;
theItem = myListItems.item(3);
trace(theItem);

itemOrdered(itemIndex:int)

Returns the item in the sorted list (as determined by the “LIST ORDER” parameter) at the itemIndex specified.

var theItem:String;
theItem = myListItems.itemOrdered(3);
trace(theItem);

itemCount()

Returns the total number of items in the list

var theItemCount:Number;
theItemCount = myListItems.itemCount();
trace(theItemCount);

itemIndex([itemName:String])

Returns the array index of the itemName passed to the function in original list. If the parameter is left blank, the default item index returned is for the last item returned by nextItem(). Indexes returned start at 0 as with standard ActionScript arrays. If the item is not found, -1 is returned.

var theItemIndex:String;
theItemIndex = myListItems.itemIndex("mysong.mp3");
trace(theItemIndex);

itemIndexOrdered([itemName:String])

Returns the array index of the itemName passed to the function in ordered list. If the parameter is left blank, the default item index returned is for the last item returned by nextItem(). Indexes returned start at 0 as with standard ActionScript arrays. If the item is not found, -1 is returned.

var theItemIndex:String;
theItemIndex = myListItems.itemIndexOrdered("mysong.mp3");
trace(theItemIndex);

Last modified October 20th, 2013