25lines entry browser

I’m a big fan of the 25-Line ActionScript Contest and will take part in the current (January) contest. I’ll come back to that in some future post surely.

All entries of the first contest (November / December) have been published on December 29th, but it is hard to browse them, because you can download an archive containing the txts only.
It took way too long looking through them all, so I decided to make things simpler. It was time to create an easy 25lines browser.

So, here it is: 25lines entry browser for Dec. 08
Have fun!

How I’ve done this
The first task was to publish all the SWFs. It would have taken hours to do this manually (open txt, copy&paste script, run test, rename swf).
I’ve always wanted to do some JSFL stuff and this was the opportuneness.
It took not very long to get started due to this two blog posts: JSFL FLA Batch Compiler by gskinner and CS4 MetaData JSFL Script by Keith Peters.


var lastId = 92;

function execute() {
	// open tester.fla
	var testerUrl = fl.browseForFileURL("open", "Please select the tester.fla", false);
	var dirUrl = testerUrl.substr(0, testerUrl.lastIndexOf("/") + 1);
	fl.openDocument(testerUrl);

	// get frame
	var doc = fl.getDocumentDOM();
	var tl = doc.timelines[0];
	var layer = tl.layers[0];
	var frame = layer.frames[0];

	// loop
	for (var i = 1; i <= lastId; i++) {
		var idString = addZeros(i);
		if (!FLfile.exists(dirUrl + idString + ".txt")) continue;
		var code = FLfile.read(dirUrl + idString + ".txt");
		frame.actionScript = code;
		doc.exportSWF(dirUrl + "" + idString + ".swf", true);
		FLfile.write(dirUrl + "idmap.txt", "," + i, "append");
	}
}

function addZeros(n) {
	var str = n.toString();
	while (str.length < 3) str = "0" + str;
	return str;
}

execute();

Maybe there would have been a simpler way without the tester.fla.

Now I created the html page, which wasn’t very difficult.
It uses an iframe to load the SWFs.

You can download the complete project and run it on your local machine.
When the current contest’s codes are released, you will of course be able to browse them here.

Leave a Comment