| Documentation for the Bgx Flexible List (Flash MX 2004) | Version 1.0.3 2005-02-05 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Introduction The Bgx Flexible List component provides list logic to create dynamic lists using virtually any MovieClip you like, giving you total freedom in the way your list items may look or behave. Easy implementation Simply assign any MovieClip as the clip to use for the list items. The component will automatically take care of repeating the item, scroll options etc. To implement event handling you only have to:
No implementation of further ActionScript is necessary, however the component automatically assigns the variables itemIndex and data to each item instance that can be used for custom functionality like presetting checkboxes etc. TextFields named following a naming convention will automatically be bound to specified properties in the dataProvider. Functionality The BGX Flexible List provides most of the properties provided by the Macromedia List Component and some more, like:
The component does not provide scrolling logic of its own but can easily be used with the Macromedia ScrollPane component. Example Library The component comes with a library of sample item clips that will be available from the Common Libraries after installation. Use this clips as-is or to start off your own customizations. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Deployment The Bgx Flexible List component is delivered as MXP file and must be installed with the Macromedia Extensions Manager. After the installation, the actual List Component that will be available from the components panel and a library of sample itemClips will be available from Window>Other Panels>Common Libraries>Bgx List Item Samples. To create a list using the Bgx Flexible List component you must either drag an instance to the stage and set the appropriate properties or, to use it within an instance of the ScrollPane component, must have a copy of the component in the library. You can find several examples of how to populate the Bgx Flexible List component within or without the ScrollPane component at http://www.bgxcomponents.com/flexibleListExamples.htm Note: If you drag an instance of the component to the stage you will see only an icon marking the position. If you export the clip the icon will not be visible anymore. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Reference Bgx Flexible List Component
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Understanding the Bgx Flexible List Component The General Logic: itemClip and dataProvider structure Note: The following tries to explain the concepts behind the Bgx Flexible List. If this appears too abstract to get you started immediately, try the examples at http://www.bgxcomponents.com/flexibleListExamples.htm The Bgx Flexible List Component is basically a Class that can create vertical lists or lists with several horizontal repeats by creating repeated instances of another MovieClip, specified as the itemClip for the list. The base for the number of replication builds a dataProvider that is an Array of Objects, each Object containing the data that shall be bound to the individual items. A simple example for such an Array would be the following: var ListData = new Array(); for (var i = 1; i < 11; i ++) if ( i == 1 || (i >
4 && i < 8) || i >= 9) If you define the example ListData Array as the dataProvider for a list instance, 10 instances of the assigned itemClip would be created, whereby the corresponding ListObj would be passed to each of these instances as the data upon which to build the item display. Similar as with the Macromedia List component each item gets assigned a data property. But by default this is the entire Object (in our example a ListObj) associated with a list item instance. (You cannot have a simple String or a Number as the item data). As you usually would use the Bgx Flexible List to create lists more complex than the standard List Component would allow, this has the advantage that you always have the whole range of data available that you might need. While our example is still quite basic, using just a flat Array of Objects, you could just as well use multilevel Arrays and complex Objects as the properties of the first level Objects. Note: assigning the Object to the itemClip
does not create a new instance of that data, it just means that the
data property in the itemClip points
towards a defined Object within your dataProvider. This has two implications: listInstance.getItemAt(2).data.price; or listInstance.dataProvider.getItemAt(2).price; or ListData[2].price; But now lets see how this data can be used to actually define the display of a list item. reference overview back to top
Built-in Databinding: TextFields and Icon Other than with the Macromedia List component there is no concept of label with the Bgx Flexible List. As you would usually want to create more complex lists with Bgx Flexible List a single label field is not much use. However there is a way to automatically bind text to TextFields and to display a standard icon at the beginning of the item, that makes the Bgx Flexible List easy to use for often needed multi field lists. If you want to use the built-in databinding mechanism for TextFields you simply have to add any number of TextFields to your itemClip and name them tb0, tb1, tb2, etc. They can be placed wherever you like. You can then define, via the columnNames property of the list, properties of your data objects as the properties to use to populate these TextFields in order. In our example you could use e.g. Again you can find an example of that at http://www.bgxcomponents.com/flexibleListExamples.htm Note: Strictly speaking there aren't necessarily columns in the Bgx Flexible List. The name columnNames was chosen to resemble the databinding used with the Macromedia DataGrid component. To display an icon you must have a MovieClip with a defined linkage name in the library. You can then specify a property within your data Objects that refers to that linkage name (or names if you have more than one). To display an icon you have to define which property of the data Objects holds the information for the icon to use. In our case you could use: listInstance.iconField = "icon"; Also for that you can find examples at http://www.bgxcomponents.com/flexibleListExamples.htm reference overview back to top
Custom Databinding: Accessing the data Object from within the itemClip If you want more customized binding options you can access the data property from within the itemClip you use to basically do with it whatever you want. For instance: at http://www.bgxcomponents.com/flexibleListExamples.htm you can find examples of lists that use CheckBoxes (see also the CheckBox examples in the sample files that come with the component). The itemClip for these examples contains one CheckBox named cbx. To automatically check/un-check the box when the list gets populated you can add the following line the first frame in the itemClip: cbx.selected = (data.description.indexOf("Drawing") > -1); The data property is passed on to the itemClip right at creation. It is instantly available, you do not have to retrieve e.g. the data for the list index from the list.
reference overview back to top
Understanding itemClips: rowBtn and bgClip We have already mentioned the itemClip several times without really explaining what it is. An itemClip can be any MovieClip in your library. It must have a linkage name defined. To use it as the itemClip for your list simply set the value of the itemClip property to the linkage name of the MovieClip you want, like: listInstance.itemClip = "BgxListBasicCheckboxes"; We have already mentioned that an itemClip can contain TextFields named tbx0, tbx1,.. for easy databinding. Apart from that there are two further Objects that are expected by the List in an itemClip (but don't necessarily have to exist). rowBtn The first one is any kind of Button with the instance name rowBtn. In the samples that come with the components that is usually a transparent hotspot. The list component automatically assigns the necessary functions to trigger itemRollOver, itemRollOut and itemPress events to that button. The reason why those functions are not simply assigned to the itemClip as a whole is that you may not want e.g. the whole area of an item to be active. Maybe only a certain TextField or image shall have that functionality. In this case you can simply move the hotspot to the desired position in a layer above the object you want. Another reason is that you may want to have objects above that rowBtn that shall not trigger the list events, like a CheckBox or a TextInput. By having a physical Button on a layer you can arrange the itemClip the way it suits you. As mentioned the functionality of triggering the list events can also be assigned to other Objects by calling the triggerItemPress, triggerItemRollOver and triggerItemRollOut functions of the list. The list itself is accessible as the _parent of the itemClip. Have a look e.g. at the BgxListBasicCheckboxes example from the Sample Library which has no hotspot but assigns the trigger functions to a CheckBox instead: cbx.onRollOver = _parent.triggerItemRollOver(itemIndex); bgClip The other Object that is expected is a four frame MovieClip with frames labeled "default", "selected", "rollover" and "selectedover". There must be a stop() action in the first frame. Each of this frames can contain any kind of code or graphics that modify the appearance of the itemClip. This can be a simple background graphic or code to change the text color of text fields, load an image etc. The list component will send this bgClip to the appropriately labeled frame when state changing events occur and thus trigger the change in the appearance of the itemClip. While you can do very sophisticated things with that mechanism, the mechanism itself is deliberately simple, allowing you to quickly and easily create a library of re-usable effects without having to modify and deploy e.g. CellRenderer classes. As the bgClip is another MovieClip various combinations of itemClips and bgClips can be used. In fact this is how the Sample Library is built. reference overview back to top Scrolling While the Bgx Flexible List itself does not provide its own scroll mechanism it can easily be used with the Macromedia ScrollPane component. You can find an example implementation at http://www.bgxcomponents.com/flexibleListExamples.htm reference overview back to top Event handling The change, itemPress, itemRollOver and itemRollOut event all return an eventObject to the assigned event handler that contains the following properties that point directly to the itemClip instance: eventObject.item:MovieClip eventObject.itemIndex:Number eventObject.itemData:Object You find an example of how to catch and process events at http://www.bgxcomponents.com/flexibleListExamples.htm#app2
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
BgxFlexibleList class Inheritance: MovieClip > UIObject class > UIComponent class > BgxFlexibleList ActionScript Class Name: bgx.BgxFlexibleList To reference the BgxFlexibleList component e.g. in a class file use the following: import bgx.BgxFlexibleList; class myClass |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Properties
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| reference overview back to top
Methods
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
reference overview back to top
Events
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| reference overview back to top
Keyboard Input
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
© 2004 Bernhard Gaul, Documentation version: 2005-02-05 |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||