Here are a few useful controls written in Flex 4 for displaying prompt text, and for showing an icon in a button.
The IconButton class extends the defaults Flex 4 Button class, and adds the icon style as well as the labelPlacement (left, right, top, bottom) and paddingLeft, paddingTop, paddingRight, and paddingBottom styles.
I also made a simple extension of the TextInput class which shows a prompt text when the text input is empty and not in focus, it is called PromptingTextInput.
The third example is called ClearTextInput, it extends PromptingTextInput to show a small clear button (which is a IconButton) on the right hand side of the text input whenever there is text inside the text input.
The fourth example is what I call a PromptingList. It shows a prompt text whenever the list is empty. This is useful if you have a list that gets populated from a remote service (e.g "Loading..."), or if your list gets items added to it by the user, or by dragging items into the list (as in the example below).
Each of the prompting controls supports a style called promptStyleName which lets you set the styleName for the prompt Label.
** Note that the package structure has been renamed to flex.utils.spark.* for all Spark controls.
Here it is:
Wednesday, April 21, 2010
Tuesday, April 20, 2010
Divider Background Color
Here is a simple component that extends the Flex 3 mx.containers.DividedBox class to provide two styles for filling in the background behind each divider.
My component is creatively called flex.utils.ui.DividedBox. It has all the same properties and styles as its parent, plus these two styles:
Here it is in action (View Source enabled):
My component is creatively called flex.utils.ui.DividedBox. It has all the same properties and styles as its parent, plus these two styles:
- dividerBackgroundColor - the background color behind each divider, defaults to #000000.
- dividerBackgroundAlpha - the alpha value for the background color, defaults to 1.
Here it is in action (View Source enabled):
Labels:
background,
color,
DividedBox,
Divider
Wednesday, March 31, 2010
Tree Item ToolTips
Here is how you can set custom tooltips in Flex 3 on each item in a Tree.
First, you have to set the following properties on the Tree:
Also note that if you set the dataTipField property on the tree instead of the dataTipFunction then your tooltips will only show up when the tree item isn't fully visible due to scrollbars. By setting the dataTipFunction it forces the tooltips to always show when the mouse is over the tree node.
Now, on to the next problem. By using the method above the tooltips are always displayed. But the default position for the tooltip is right on top of the tree node, which is annoying. So this is why we use our own custom item renderer so that we can position the tooltip below or above the node (or anywhere you want it).
Here is an example with View Source enabled:
First, you have to set the following properties on the Tree:
- showDataTips="true" - causes tooltips to be shown
- dataTipFunction="myDataTipFunction" - sets the function which returns the tooltip for each item
- itemRenderer="ToolTipItemRenderer" - tells the tree to use our custom renderer (which extends the default TreeItemRenderer)
Also note that if you set the dataTipField property on the tree instead of the dataTipFunction then your tooltips will only show up when the tree item isn't fully visible due to scrollbars. By setting the dataTipFunction it forces the tooltips to always show when the mouse is over the tree node.
Now, on to the next problem. By using the method above the tooltips are always displayed. But the default position for the tooltip is right on top of the tree node, which is annoying. So this is why we use our own custom item renderer so that we can position the tooltip below or above the node (or anywhere you want it).
Here is an example with View Source enabled:
Labels:
itemRenderer,
positioning,
tooltips,
Tree
Wednesday, March 17, 2010
Custom Components Live Preview (Design Mode)
If you have created your own component and you drag it onto your Flex app in Design Mode and it appears as a tiny almost invisible square on your screen, then watch the video below to see how you can get it working properly (like the default controls do).
I found this awesome video tutorial on YouTube that explains how you can create what is called a Live Preview of your component so that your custom component actually appears with the right appearance and dimensions.
Be sure to check out the author's blog at blog.flashgen.com.
The end result that I learned from this video is that if you have a Flex Project which contains your custom component, and you try to use it in an MXML file then it won't work properly. If the custom component is in a separate Flex Library Project (or SWC) then it will work properly.
I found this awesome video tutorial on YouTube that explains how you can create what is called a Live Preview of your component so that your custom component actually appears with the right appearance and dimensions.
Be sure to check out the author's blog at blog.flashgen.com.
The end result that I learned from this video is that if you have a Flex Project which contains your custom component, and you try to use it in an MXML file then it won't work properly. If the custom component is in a separate Flex Library Project (or SWC) then it will work properly.
Labels:
custom component,
design mode,
live preview
Thursday, March 4, 2010
DragHandle, ResizeHandle
Here are two customizable drag and resize handles:
You can set the following properties:
You can set the following styles too:
These two components are used in all the Resizable Containers.
You can set the following properties:
- rows - sets the number of rows of dots
- columns - sets the number of columns of dots
- dotSize - sets the dot size (defaults to 2)
- dropShadowEnabled - sets whether a drop shadow is used (defaults to false)
- dropShadowColor - sets the drop shadow color
- keepOnTop - if true then the handle will be on top of the other sibling components
- positionResizeHandle - If true then the resize handle will be positioned in the bottom right corner of the parent (ResizeHandle only)
You can set the following styles too:
- backgroundColor, backgroundAlpha - sets the background color alpha for the drag/resize handle
- dragHandleColor, dragHandleAlpha - sets the color and alpha value for the drag handle
- resizeHandleColor, resizeHandleAlpha - sets the color and alpha value for the resize handle
These two components are used in all the Resizable Containers.
Labels:
drag handle,
resize handle
Subscribe to:
Posts (Atom)