Avg. Rating 3.5

Problem

I have a custom component being distributed as a SWC file. I need to be able to differentiate whether the component is being used normally or if it is being shown in the design view.

Solution

UIComponentGlobals.designMode can be used to check if we are being run from design view or not.

Detailed explanation

UIComponentGlobals.designMode is a global variable that lets you differentiate if your component is being run from Flex Builder's design view or not.
 
For this to work, your component must be packaged in a SWC.
 
import mx.core.UIComponentGlobals;


private function onInitialize():void
{
  if ( UIComponentGlobals.designMode )
  {
    // show something design view specific
  }
  else
  {
    //render normally
  }
}
 
This is useful in cases where your packaged component has to draw a placeholder in design view or if in any manner it needs to behave differently in design view. 
Report abuse

Related recipes