So I want to get the domain where the flash swf is being played and not the location of the file. If only I could get ExternalInterface
to return the value like so:
var domain:String = ExternalInterface.call("document.domain");
But the above produces null
.... Its an banner ad so I can't pass any flashvars
to it or call custom js
functions
It returns null
because you're not calling nothing:
document.domain
is the name of a variable, not a method call.
Try return document.domain
instead.
EDIT:
The correct syntax is to create an anonymous function that returns the document's domain:
import flash.external.ExternalInterface;
var domain:String = "";
if (ExternalInterface.available == true)
{
try
{
domain = ExternalInterface.call("function() { return document.domain; }");
}
catch (err:Error)
{
domain = "Error: " + err.message;
}
if (domain == null) domain = "No domain"
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.