Actionscript 2 utility class: Grid
I’ve been working on a project with fullscreen flash. Everybody who has worked with something like this, or even without working with something like this probably knows that a grid for checking positioning can be handy. Well, I know I thought so, so I wrote this simple utility class.
Below is an example, you can enable it with theSPACE key (click inside it first, to give it focus). Change resolution with the arrow keys.
It’s nothing special or new, I know, but still can be very helpful.
Update: Hehe, since my tilde key wasn’t working for anybody else, i changed the default key to SPACE. You can of course change the response key, just use Grid.key = keycode
Comments
6 Comments
2007-04-29, 8:42 by Jon B
It doesn’t appear to work with Flash Player 9 – both your example above and the when I test the source .fla (inside flash cs3)
2007-04-29, 14:10 by Antti Author comment
That’s weird – it works for me. I’m guessing it’s the keycode (i’m not using an american keyboard)? If so, you could just change the default code in the class or do something like this:
Grid.key = Key.SPACE;
Grid.create( );
2007-05-05, 14:10 by Ola Muldal
Its not working here either (nor IE or Firefox), just a bluescreen
(fp 9.0.45, norwegian keyboard)
2007-05-05, 14:25 by Antti Author comment
Should work now, changed the default key to space.
2007-05-07, 23:55 by Amit
Hi,
that’s very cool, but will you kind enough to give a real world example of when to use it? why not just giving coordinates to object on stage when the screen gets bigger via an event listener, why check/compare it with the grid??
2007-05-08, 10:11 by Antti Author comment
Well of course you calculate the coordinates yourself, move stuff around and so on, but sometimes you want to (or well, i do) check.
A “real world” example: A movieclip doesn’t have it’s anchor point in the middle, but a bit off. This might be because you want to rotate the mc around something that’s not in the middle. If you move the mc, you have to count in that anchor offset, and with the grid you can quickly check it’s correct. Still, if you can’t come up with a reason to use it, you probably don’t need it
It’s not a super useful class but can come in handy, something i wrote in like 5min and thought i’d share with you guys. Also it can just be in the background and you just hit your key to show it when you need it (just remove it when the site goes live)
Post a comment