Log In  
  Getting Started  
----------------------------------------

Resources

 

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.

previous page next page

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

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

  • Question: I want to take a chunk of xml and convert it to an URLVariable. So I have:
    <root>
      <item1>blah</item1>
      <item2>anotherBlah</item2>
    </root>

    And I want to end up with something like this:

    Var urlVar:URLVariables = new URLVariables();
    urlVar.item1 = blah;
    urlVar.item2 = anotherBlah;
  • Answer: I think it goes something like this:
    var xml:XML = <root>
                <item1>blah</item1>
    
                <item2>anotherBlah</item2>
    
                </root>
    
     
    var urlVar:URLVariables = new URLVariables
    var xmllist:XMLList = xml.*;
    var n:int = xmllist.length();
    for (var i:int = 0; i < n; i++)
    {
        urlVar[xmllist[i].name()] = xmllist[i].toString();
    }
previous page next page
Added by Randy Nielsen , last edited by Randy Nielsen on Mar 06, 2008  (view change)
Labels: 
(None)

Powered by Atlassian Confluence 2.7.1, the Enterprise Wiki. Bug/feature request - Atlassian news - Contact administrators