Saturday, 4 June 2011

Flex, Determining which server/domain a SWF is hosted on


situation

Here’s a handy tip which can help you when deploying Flex applications on mulitple servers (such as a staging/production server). Basically you can listen for the Application tag to dispatch the applicationComplete event, grab the URL of the SWF using the loaderInfo.url property, and then use the URLUtil.getServerName() method to parse out the server name.
problem

adobe flex4 flex 4.0 AS3.0
Determining which server/domain a SWF is hosted on |
How to get the domain where the swf is hosted
----
> page: dn
difficulty level

0/10 :)))
compatibility

flex4, as3
solution

In prior version of Flex 4.0 use this:
URLUtil.getServerName(Application.application.loaderInfo.url);

In 4.0 use this: because Application is no longer available in 4.0 URLUtil.getServerName(FlexGlobals.topLevelApplication.url)

No comments:

Post a Comment