Flash? Pure Evil

posted May 29th, 2006, 7 comments, tagged

I’ve been working on adding support for a few hours tonight, when I ran into the problem that eval() in ActionScript cannot compute anything. That’s right, the only thing it is good for is for referencing variables! Like we couldn’t do that in a better way already!

Anyhow, I needed eval() so you can configure filters on the client side. Therefore, my own implementation:

private static function eval(str) {
  var as;

  if(str.charAt(0) == '{') { // Ah, we need to create an object
    as = {};
    str = str.substring(1, str.length - 1);
    var $ = str.split(',');
    for(var i = 0; i < $.length; i++) {
      var $1 = $[i].split(':');
      as[$1[0]] = sIFR.eval($1[1]);
    }
  } else if(str.charAt(0) == '"') { // String
    as = str.substring(1, str.length - 1);
  } else if(str == 'true' || str == 'false') { // Boolean
    as = str == 'true';
  } else { // Integer
    as = parseInt(str);
  }

  return as;
}

Eat that, ActionScript!

Oh, and filters seem to be working. Check out the demo and download the latest nightly. Fun!

P.S. I’m going to be in Copenhagen from Wednesday until Sunday for Reboot. If you’re there, say hi!

7 responses

  1. Evan says:

    Not a big deal, but I thought you’d like to know that Google Reader isn’t decoding some of the entities in your entries. Specifically, the apostrophes (’)

    And as a user of Linux on AMD64, yes, Flash is evil. I take that back. Flash isn’t inherintly evil, but people who don’t understand the concept of progressive enhancement (or at least graceful degredation) are evil, and Flash is guilty by association.

  2. Mark Wubben says:

    Well, in this case it’s probably ActionScript which is evil. Nonetheless, I’ve run into a number of issues working on sIFR, and it’s just as annoying – if not worse – than cross browser problems.

  3. new Boolean(‘true’) isn’t quite the same as true. I would change that line to str == ‘true’.

  4. Mark Wubben says:

    Ah, good point Sjoerd. Magic Boolean strikes again.

  5. Nice, although when selecting sIFR’ed headers, they become unreadable. Is this a player and/or filter ‘feature’?

  6. Mark Wubben says:

    This appears to be because of the knockout effect, but I’ll be doing some more research.

  7. Jeph says:

    Yea, I think that the highlighting effect on the “New agreement creates Myriad opportunities for Fruitiger, sans-serifs” is due to the specific filter used, although I wouldn’t know what you could do to solve it.