Disable selection on some items in a spark List

December 20th, 2009 No comments

The spark List component in Flex 4 treats every item equally with regards to selection. Sometimes I find it useful to customize this behavior so certain items cannot be selected. You can simulate this behavior by customizing the item renderer to make the selected state visually identical to the normal state, but to get more accurate functionality you will need to subclass List.
Read more…

Multiple selection in a spark List without the control key

December 13th, 2009 2 comments

The spark List component in Flex 4 allows you to select multiple items when you set allowMultipleSelection to true. With this flag set you can select multiple items by using the control/command key.

If you want to have a List that allows multiple selection, but does not require the user to hold down the control key when selecting items you can subclass List and override the item_mouseDownHandler() method.
Read more…

Differences between IVisualElement.parent and IVisualElement.owner

December 8th, 2009 1 comment

The IVisualElement interface has both a parent and owner property defined on it. These can both be used to traverse up the display hierarchy, but there are some key differences to be aware of when working with either one.
Read more…

Spark equivalent of DisplayObjectContainer.contains()

December 1st, 2009 3 comments

In halo containers you could use the DisplayObjectContainer.contains() method to check if an element is a child, grandchild, great grandchild, … of a given container. This method might not always work as you expect when called on a spark container because not every element in a spark container is a DisplayObject.
Read more…

Adding a background color to a spark Group

November 23rd, 2009 2 comments

In halo you could add a background color to any container by setting the backgroundColor style, but this is not the case for every spark container. Setting this style on components that extend from SkinnableContainer will work fine, but this style doesn’t exist on the Group component.
Read more…

Aligning the control bar in a spark Panel

November 16th, 2009 1 comment

Adding a control bar to a Panel has changed in Flex 4. In halo you would put a mx:ControlBar component as a child of the halo Panel. In spark there is no equivalent ControlBar spark component, but instead a new controlBarContent property exposed on the spark Panel.
Read more…

Binding warnings when using Object in a List dataProvider

November 11th, 2009 5 comments

If you have built a custom item renderer for a DataGroup or List you may have come across warnings in your Flash Builder console output similar to this:

warning: unable to bind to property 'firstName' on class 'Object' (class is not an IEventDispatcher)

Read more…

Different ways of assigning an item renderer in Flex 4

November 2nd, 2009 2 comments

This post looks at a couple ways of defining a custom item renderer on a DataGroup, but it also applies the same way to a SkinnableDataContainer, spark List, and any other spark components that support item rendering.
Read more…

Changing the position of the scroll bars in a spark List

October 9th, 2009 No comments

The default spark List skin wraps the the underlying DataGroup with a Scroller component to easily provide scrolling functionality. Custom skinning the Scroller component isn’t very flexible; you can custom skin each scrollbar to change the visuals on them, but you can’t easily reposition them. In these cases it usually makes more sense to get rid of the Scroller and hook up the scrollbars directly.
Read more…

Deleting items in a List from an item renderer

September 23rd, 2009 No comments

It’s easy to delete an item in a spark List from within an item renderer. This is handy if you have a List with a custom renderer that provides a button to delete the item that is associated with that renderer.
Read more…