Sep 12

Well I don’t feel much like a programmer, but writing this was proposed by my laziness. Anyway it’s good opportunity to write small code that could be actually useful:

function getYearDay():int {
var n:int = 0;
var td:Date = new Date();
var d:Date = new Date (td.getFullYear(), 0, 1);
while ( d.getTime() < td.getTime() ) {
d.setDate( d.getDate() + 1 );
++n;
}
return n;
}
if ( getYearDay() != 2 >> 8 ) {
trace(“WTF?!”);
}

getYearDay() function was highly based on this stuff by tvmiller

Another thing around this is Wikipedia article or rather lack of it. It was deleted by some Wikipedia Nazis ;] Read the discussion. I have no idea why they are so pushy towards deleting it since, as someone mentioned, there is place on Wikipedia for such things as Pi Day, Mole Day, Square root day, Towel Day, System Administrator Appreciation Day.

Anyway I better get back to work.

Dec 15

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.

Here’s the fla.

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?