Jesse Hallam wrote:
> 
> I've taken some time to search these archives, as well as other 
> resources on the web, but cannot come to a definitive conclusion:
> 
> 1) When a .swf is accessed directly, through a browser, what is the 
> correct way to access the fully qualified URL? ( i.e. 
> http://www.mydomain.com/files/flexapp.swf 
> <http://www.mydomain.com/files/flexapp.swf>). There are a number of 
> posts about using mx.core.Application.application._url, but this is 
> undefined for me.

  It should work w/o problems:

import mx.core.Application

Application.application.url   (<--- no underscore )

> 2) When a .swf is accessed by being embedded in an html page, what is 
> the correct way to access the fully qualified URL? Again, a number of 
> resources point me to using a javascript solution, but I'm surprised I 
> can't gain access to this information directly from Flash/Flex and have 
> to rely on an external dependency.

  You cannot access the Fully qualified URL to the page containing the 
swf from within Flash.  You can use external interface and write some 
JavaScript to get it, though:

  Some AS3:

public var URL : String = ExternalInterface.call('getURLnoParameters');

  And the JavaScript function you put in the wrapper HTML page:

function getURLnoParameters(){
  return document.location.href.split('?')[0];
}

  In theory you can do this all w/ AS3, but this is untested:

public var URL : String = 
ExternalInterface.call('document.location.href.split('?')[0];');


> Why do I need this information? My Flex application could be served from 
> any hostname, and I need to establish a socket connection (requiring an 
> absolute url) back to the server hosting the .swf to do some RPC.

  Or you could put all your RPCs on the same domain and set up a 
crossdomain.xml file so that all the 'any hostnames' can access it. 
Just an idea.


-- 
Jeffry Houser, Technical Entrepreneur, Software Developer, Author, 
Recording Engineer
AIM: Reboog711  | Phone: 1-203-379-0773
--
My Company: <http://www.dot-com-it.com>
My Podcast: <http://www.theflexshow.com>
My Blog: <http://www.jeffryhouser.com>

Reply via email to