-
detecting the url of a SWF (so i know if its playing as a file or in a bowser)
i used to use a simple technique to detect weather the swf was playing in a bowser or as a file in the flash authoring environment. i did it so that i could have different file paths for eternally loaded content depending on weather i was looking at it in a bowser or as if i had just ctrl + retuned in flash
AS2 code:
Code:
phpPath = (_url.charAt(0) == "f") ? "http://localhost:8888/blunt_new/inc/" : "inc/";
if the swf was running in the authoring environment or you had just double clicked a swf in the operating system the first part of _url would be "file....." rather than "http://....."
so my question is how do i get at the the swf's URL in AS3? or is there a better way of detecting whether its running in the browser or as a stand alone SWF?
-
sorted it my self after a night sleep
stage.loaderInfo.url
is just me or is AS3 documentation not as goos as it was for AS2?
-
Senior Member
Just be aware that loaderInfo.url isn't really bulletproof. In other words, don't rely on that alone for security purposes, e.g. deciding whether an .swf is running in a sanctioned environment or has been stolen and placed on somebody else's page. For one thing, your code can be decompiled and that variable changed. Or the path can be spoofed.
loaderInfo and Loader.contentLoaderInfo are a tricky junction in as3, it always struck me as an untidy seam in the fabric, although far be it from me to suggest a better way of doing things.
-
I don't know if I am too late (digged this post while searching how to do that myself), but you can use Capabilities.playerType
check it here
If you don't want to click the link, here's how it goes:
Code:
import flash.system.Capabilities;
var playerType:String = Capabilities.playerType
switch(playerType){
case "ActiveX":
trace("I'm a IE ActiveX");
break;
case "Desktop":
trace("I'm an Air app");
break;
case "External":
trace("I run in an external flash player");
break;
case "PlugIn":
trace("I run in a webpage in a non-IE browser");
break;
case "StandAlone":
trace("I run in a standalone flash player");
break;
default:
break;
}
Hope it's still useful
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|