diary : entry

ActionScript No Longer Sucks So Much

20th January 2005 at 02:38
Oh how I hate ActionScript. I was fed up with it not having hashes, so I wrote my own hash algorithm. It's called like this:
#include "hash.as"
myHash = new Hash();
myHash.set("this key", "some value");
myHash.set("that key", randomObject);
thisText = myHash.get("that key");
Yes, I am lame. I even automatically generated documentation using my automatic documentation generator, and I have added a new section called flash, where my various exciting outings with flash will go. Please let it end here.

Comments

  1. If it's anything like JavaScript, can't you just use objects as hash tables?

    myHash = new Object();
    myHash['key'] = 'value';
    value = myHash['key'];
    Simon Willison20th January 2005 at 16:20
  2. If it was anything like JavaScript you could, but alas, it's not. At least I haven't found anywhere that says it is, just lots of people saying it's not. The closest is using a variable with the name of the key, like:

    set("crapHash."+key, value)
    value = eval("crapHash"+key);

    But that's rather annoying...
    radiac20th January 2005 at 17:53
  3. Maybe I'm missing something, but would Actionscript's associative arrays do the same thing? I hash movieclip objects into an array to look up stuff, before I realized I could just stuff the associated object into the movieclip object itself.
    Dave28th January 2005 at 00:31
  4. I may be wrong but I think associative arrays came along in MX 2004, I'm working in MX 2002.
    radiac28th January 2005 at 01:00
  5. Hashes aka objects have been around since Flash 5. Use it just like Simon Willison described
    nick18th February 2005 at 21:48
  6. Ahh, so they have. Oh well.
    radiac19th February 2005 at 01:33

Add a comment

Name:(required)
E-mail:(will not be made public)
Website:
Comment:
Fruit: Your fruit of the day is:


Please enter it below:

Thank you for proving you are a human, not a spammer!
 

Links