Tips, tricks, and techniques
This page lists tips, tricks, and coding techniques for Adobe Flex 3. To suggest a tip, post it as a comment and we will add it to the page.
Tip #1: Many of these items also apply to Flex 2.0.1.
|
rate-18284827-49374
| User rating? |
|
|
|
General tips
Setting a delay function
- Question: I want to delay execution of a statement, by 5 seconds. How do I go about making the function wait?
- Answer: Flash.utils.Timer is the way. There are many usage examples in the Programming ActionScript 3.0 book. There are examples later of clocks, etc. as well.
ToolTip not appearing over transparent parts of renderer
- Question: I made a custom renderer and assigned a string to its tooltip property. The renderer has a label, an image, and some blank space between and around the label and image. The tooltip only appears if you hover over the label or the image. What should I do here?
- Answer: Alpha=0
User Interface tips
Creating Pods
- Question: Does any one know where I might some already existing sample code for Flex and ActionScript that would quickly let me move "pods" around in the same manner as the old demo at http://flexapps.macromedia.com/flex/Vanilla/main.htm?
- Answer: A few links for doing MDI style apps with panels:
Setting DividedBox position explicitly
- Question: How do I set the position of a DividedBox explicitly? I tried using getDividerAt() to get the divider but that *returns a 'BoxDivider' type which I can't find defined anywhere. I then tried to just set the position, with the function moveDivider() but that does a relative move, I need to move to an absolute position.
- Answer: hdivbox.getDividerAt(0).x = 220;
Setting a Panel footer
- Question: How can I insert text in the footer of a panel?
- Answer: Use a ControlBar container.
<mx:Panel>
<mx:Label text="stuff" />
<mx:ControlBar>
<mx:Label text="footer text" />
</mx:ControlBar>
</mx:Panel>
Performance tips
Client-side performance
Charting performance
Best practice: styleName for selected items in ListBase control
- Question: We have a ListBase-based control (TileList) that has a custom itemRenderer associated with. For selected items we want things to appear differently, and the easiest way to accomplish this is by changing the styleName for the itemRenderer for selected items. I can trap all selectItem events and change the styleName for de-selected and selected items, but it seems like a lot of overhead work. Is there something easier available?
- Answer: Changing stylename is expensive. If you care about speed (which usually doesn't matter that much in a tilelist), you could grab different properties from the one stylesheet. The default renderers have textRollOverColor and textSelectionColor styles; they use instead of "color" when highlighted or selected.
XML tips
Converting XML to a URL variable