Conditionally Showing Widget Properties By Domain

Here’s a quick tip for the Flex developers out there.  In my environment, we commonly export visualizations to Flash PDF and send them externally to clients.  While we may want to add some flexibility to the visualization to allow for some customization by the user, we don’t always want the same options to be available to the client in the exported version. Here’s a very simple solution to add some level of “security” to your visualization behavior or properties.

For more information on the basic implementation of the MicroStrategy Properties Viewer, check out this post.

Since we want to show different options in Web vs PDF, we’ll want to check the domain that the SWF is running on using this property:


This will return the domain of the web server, or something like PDFLoader if it’s running in a PDF.  You can then craft a simple condition statement that will decide whether to show the Properties menu or not:

if (URLUtil.getServerName(FlexGlobals.topLevelApplication.loaderInfo.url) != "") { var propertiesMenu:ContextMenuItem = new ContextMenuItem("Properties", false, true, true);
propertiesMenu.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, propMenu);
var contextMenuCustomItems:Array = FlexGlobals.topLevelApplication.contextMenu.customItems;

 Since we’re conditionally creating the Properties menu here, you’ll need to remove this line from the initPropEditor() function:


If you always want to show the Properties menu option, but want to customize which options are available, simply add this same condition to the file when building the XML string in the getEditorLayout() function.

I used to have to get tricky in the trade off between giving options to the users and exposing those same options to clients, but now I can fully customize the experience for both groups.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *