Shout!

Regular Expression matching empty switch statements

Posted in General thoughts on February 7th, 2010 by Øyvind – Be the first to comment

In my continuing effort to track down a particularly nasty case of internal build error/classes must not be nested in Flash Builder. I ran a regex to find empty switch statements. These are notoriously known for causing this error, so in follow up to my post about regex for finding unterminated lines (another possible culprit), here is a RegExp that matches empty switch statements:

switch\s*?\(.*\).*\{\s*+\}

SlowLoader – Easy bandwidth simulation util for Flash

Posted in Freebies, General thoughts on January 6th, 2010 by Øyvind – Be the first to comment

Today I was working on a project with real strange issues related to the duration of load operations. I decided to throw together a class that would enable me to throttle the download speed of the Loader class when used locally. Simply strangle the bandwidth by entering the desired speed in the load method and you’re good to go.


Download SlowLoader.as

It works very much the same way as the Loader class with the only difference being that you add your event listeners directly to the SlowLoader instance instead of the contentLoaderInfo instance of the Loader instance. Other than that it dispatches the same events as the Loader class does so it should be fairly simple to swap it for a regular Loader when you’re done. I’ve also included and example class. Here’s an excerpt of it:

1
2
3
4
var l:SlowLoader = new SlowLoader();
l.addEventListener(ProgressEvent.PROGRESS, _updateProgress);
l.addEventListener(Event.INIT, _showImage);
l.load(new URLRequest("file.jpg"), 512, 0.9);

NOTE: SlowLoader was developed for my own use, which means that it dispatches AILoggerEvents for printing log messages from it. AILogger is also included in the ZIP file and you can read more about it here. If you do not wish to use it, feel free to strip these lines out of the class.

AS3 dictionary back to back in 4 months

Posted in Adobe Flash, General thoughts on November 9th, 2009 by Øyvind – 2 Comments

AS3 Language Reference and Dictionary

As some of you might know, I’m in layoff from my job as a flash developer at Allegro Interaktiv. I’ve been thinking hard and well about what I want to spend this period of four months doing. I will be freelancing a little if I can (in agreement with my employer of course), spend time with my family, and also catch up on a few forsaken hobbies.

But this sudden abundance of free time obviously creates a pefect climate for getting up to speed on new Flash libraries and dig deeper into the ones I already know. Like the AS3 core classes. That’s why I’ve given my self a perhaps rediculous challenge; to read the complete ActionScript Language Reference back to back over the next four months. This is clearly perversely nerd-like and all that, but here’s why.

The case for reading it all

Actually I’ve been thinking about it for a few years. You see every time I look up a class or a method in the dictionary, I usually read one or two paragraphs more than I need. Often I learn something new that’s been sitting just below the surface of what I already know. At times the AS3 language reference is not even that badly written and the examples are usually useful. So instead of googling for tutorials about particle engines, Papervision and what not, I decided that before trying to gain something completely new I’d be better off getting to know the old annoying aunt intimately. Well not in that sense… sorry, you know what I mean.

You should too!

I’m not saying you really should join me in this preposterous endeavour, but I am serious in that many tend to overlook what a great resource the AS3 Language Reference really is. So the essence is really that you can learn a lot from what you already have at a single keyboard command (shift-F1 in Flash that is). Look up some random class name that you’ve never used an find out what it’s for. You might be glad you did.

In the mean time, you can follow my progress here at the blog, and if you follow me on Twitter.