Faris Faris - 4 months ago 19
ActionScript Question

Grab URL through Java/Actionscript/JavaScript?

this is what I'm looking to do.

I have an ActionScript 3.0/Java bridge, basically the SWF (front end) sends commands to the Java through RTMP and the Java processes it.

What I want to do is a URL check to check if the SWF that's sending commands to the Java is being ran on a specific URL, if the URL doesn't match what I put in the if statement then the function won't continue.

How am I supposed to do such a thing?

Answer

If you're working in a loaded swf you can use loaderInfo:

    trace(this.loaderInfo.url);

if not you can check the external interface (if you're swf is embedded in an HTML)

    if (ExternalInterface.available == true){
    if (ExternalInterface.call('document.location.href.toString') != null){
        trace(  ExternalInterface.call('document.location.href.toString')); 
    }}
Comments