AprilScript: ActionScript worst practices
In honor of the date, and in the spirit of the old Obfuscated C Code Contest, I’ve written a bit of code to demonstrate some of the more, shall we say, interesting things you can do with ActionScript.
The code:
package {
import flash.display.*
import flash.text.*
public class AprilFools extends Sprite {
エイプリルフール var Number = 4..toString()
use namespace エイプリルフール
function AprilFools()
{
get = set
set = get
with (createTextField())
text = new Date(Number).toDateString()
}
function get get() { return Number + <><{Number}
b={"/"+Number.split(/\//)[0]*502.25}/></>..@b }
function set get(set) { Number = set+'/'+set/4 }
function get set() { return Number }
function set set(get) { Number = get }
// nothing fun here
function createTextField():TextField
{
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
var textField:TextField = new TextField();
textField.width = 1000;
addChild(textField);
return textField;
}
}
}
namespace エイプリルフール
The program’s weak spot is creativity in terms of what it actually does — just some static text output. Pretty pathetic really. All my effort went into the ActionScript. Click here to see the result. It’s probably not worth the effort to try to figure out what it does before running it; that’s not really the fun part. The fun part is trying to figure out why the heck the thing compiles at all; what the individual lines of code actually mean; and what sick features of the language I am taking advantage of. Tell me what you find.
Comments(5)
‘with’ keyword is still alive? That’s a time saving sick language feature. I loved using it except i was told back in the day not to use it for performance reasons.
Yep, "with" is still with us. It does have a performance impact, although personally I feel that impact is overstated. My bigger problem with "with" is that I find the resulting code to be confusing. But if used judiciously, I think it’s fine.
Whoa. Nicely done. Holy crap my head hurts.
"return Number <><"
LOL who knew the compiler liked fish?!
[...] Morearty My brother Mike, a developer on the Flex team at Adobe, wrote a pretty impressive bit of Obfuscated ActionScript on his [...]