Urkel asked at the Kongregate forums if anyone could help him with the domain lock in AS3. Well I donât know AS3, as for me itâs still âIâll dig into it tomorrowâ, but with help from Google and Flash Help Iâve modified the first example from Flash Rightsâ Domain Control page so that itâs⌠well, maybe not pure AS3 but compiles as if it were. Anyway maybe someone will use it or will rewrite it so that it fits standards and stuff. For now it works and thatâs a start.
Here’s a live swf. It doesn’t lock anything – it just shows domain.
Source:
import flash.events.*;
import flash.display.LoaderInfo;function enterFrameHandler(event:Event):void {
var url:String=stage.loaderInfo.url; //this is the magic _url successor
var urlStart:Number = url.indexOf(“://”)+3;
var urlEnd:Number = url.indexOf(“/”, urlStart);
var domain:String = url.substring(urlStart, urlEnd);
var LastDot:Number = domain.lastIndexOf(“.”)-1;
var domEnd:Number = domain.lastIndexOf(“.”, LastDot)+1;
domain = domain.substring(domEnd, domain.length);
txt.text=domain;if (domain != “mywebsite.com”) {
// do nasty things to thief
}
}addEventListener(Event.ENTER_FRAME, enterFrameHandler);
Sidenote: I need some good AS source formatting wp plugin and sth like lighbox with swf support. Anyone?