Flashamatizing

Published March 30, 2007
Advertisement
Oooh, CS3 is out. Looks like I'll be scraping together $499 so that I can get the big suite upgrade. I actually could just update the stuff I use most (Flash, Dreamweaver, Fireworks) for $399, but if I throw in the extra $100 I also get Photoshop and Illustrator.

And that's a pretty good deal for Photoshop and Illustrator. Given that Paint Shop Pro is not unexpectedly going the Microsoft Money route of "let's change the color scheme and add a couple of tutorials, then we can charge money for a new version", I'll probably welcome the new stuff. To be honest, I'd been using Fireworks for all of my image-editing recently. For web-stuff, I love their almost-invislble scheme of maintaining two files, one a lossless PNG that stores vector-data in the PNG's metadata (i.e. "the version that don't look good on web browsers") and the optimized flattened JPG/GIF/PNG (i.e. "the version that looks good on web browsers but ain't editable worth squat"). That means that on pages like this, if I want to change the callout text or add new balloons or change the drop-shadow, it's easy to do, and it'll save out both the nice-vectored-layered-not-web-compatible version for me and the optimized-paletted-dithered-gif version for the page.

I'm hoping they extended that same workflow to Photoshop and Illustrator. It's handy as all get-out.

The new Flash supports AS3 and Flash 9. Dunno if I'm gonna move there right away, though. AS3/Flash9 is an order-o-magnitude speed improvement over the old version, mainly because the Flash9 player actually has two VM's. One that interprets the old "similar to Java bytecode, including the speed" code and one that interprets the "similar to the old stack-based P-CODE/FORTH languages that were popular in the 1980's but fell out of favor, mainly because they required you to write an actual compiler and not just a line-by-line convertor". Of course, a piece of stack-based pseudoassembly runs about a hojillion times faster than that new bytecode VM, and JIT compilers didn't turn out to be the solution to all our performance problems that the 1990's promised them to be.

"Oh, Java performance sucks? Oh, well they'll be better when they have a JIT. In fact, they'll be better than C++. Lots better! You want proof. We got benchmarks!"

"Oh, Java performance isn't very good, even with a JIT? Well then, let's model our Actionscript interpreter after that!"

In Actionscript-macrodobe's defense, Flash wasn't really intended to become the web-application programming language that it's become, so I'll forgive the clear growing pains it went through. At least they're taking big steps to fix the problem, which Java never really did because they were too busy making releases that ensured that the naming conventions for library commands were consistent.

. . .umm, I think I'm ranting. Back to the topic. Only problem is that Flash9 ain't quite ubiquitous yet. Right now my Flash7-based site will work on about 99% of browsers, including weird ones like the Wii. And that's kinda cool.


Oh, and a quick hint out there for the cheap. If you're looking to upgrade your macrodobe products, get an account at fatwallet.com and click through them to buy it and you'll get a few bucks back.

The way that works is that fatwallet is hooked up to all of those affiliate programs that give 'em a kickback if you buy a product through their site. Fatwallet, however, splits the kickback with you. If you go to their stores page, you'll see how much your cut will be.

Mind you, the cash won't come immediately. Most affiliate programs pay quarterly or on some kind of "hit a certain point and we cut you a check" system, and Fatwallet splits the cash when they get it, so it's likely that you won't get your cut for 1-3 months. Once the cash appears in your account, you can request the cash via check or paypal, which only takes a couple of days.

I've been doing this for Civilgrrl's office supplies and our Dell purchases, and I couldn't be happier. According to the site, I've gotten $209 cash back so far.

Still, the Adobe Store kickback is 6%, which is about $30 for a $499 purchase. And that's certainly worth a free sign-up.

And yeah, I know what you're saying now. You're saying "Why let them have half. Why not just sign myself up as an affiliate and take the whole thing?" Well, I've done that in the past, and it's a genuine hassle. Some affiliate programs require manual approval or some kind of odd "link builder" system that makes things difficult. Also, some companies only send you your referral bucks when you reach a certain point (usually $100), which means that your referral bucks will likely never make it to you. Fatwallet's done the legwork with the affiliates, and it's worth the cut.


Finally something programming related. AS2 and AS3, like most new languages like Python, have dispensed with the concept of statement closure. That means that you don't have to end your lines with a semicolon. Giant screens and fast text editors have made whitespace in your code very cheap, so the semicolon has become the code-equivalent of saying "umm" when you speak -- it's just something to fill space.

There is one case, though, where it's problematic, and that's the case of an empty statement. Suppose, for example, that you want to find the first null element in an array. the one-liner solution is this. . .

(note, this is actionscript, but it's durn close to C++ except that arrays have a "length" member because all actionscript arrays are dynamic)

int index;for (index = 0; (myarray[index] != null) && (index != myarray.length); index++);trace("the first non-null index is " + index);


Problem is, this is butt-ugly. You expect a for-loop to contain something to be iterated over, but in this case it's not necessary. The for-loop itself is doing everything needed, so it doesn't need a body and I can just close it.

The next problem is that most C++ compilers and syntax-checkers and lint-tools will bitch at you for it, mainly because there's about a 90% chance that that semicolon at the end of the for-loop is a mistake and will bite you in the ass once you start running and unless you debug it it's durn-near impossible to find.

Furthermore, it's a problem if semicolons are optional because the compiler assumes that the for-loop must contain something. So if I remove the semicolons from my above example. . .

int indexfor (index = 0; (myarray[index] != null) && (index != myarray.length); index++)trace("the first non-null index is " + index)


Does the trace now get called multiple times because the for-loop assumes that the line/block below it is part of the loop? It's ambiguous, and ambiguity piled on top of ambiguity isn't good.

The elegant, albeit obscure, solution to this is the following

int index;for (index = 0; (myarray[index] != null) && (index != myarray.length); index++)    null;trace("the first non-null index is " + index);


Both C++ and Actionscript interpret a null by itself as "don't generate any code", so putting the null in the block does triple-duty of making it obvious that the inside of the for-loop does nothing, removing the "you probably didn't mean to do that" warning, and also making its intentions clear in a semicolon-free universe.

This has been your code-obscurity minute. And as a bonus, it'll help your C++.

Yeah, I could've restructured the "find the first null value" code into several lines without a hit, but this one-liner is pretty easy to understand and doesn't quite make it into the "too durned clever for its own good" category that you're always encouraged to avoid.

Go in peace.
Previous Entry Happy Birthday To Blog
Next Entry Number 11
0 likes 2 comments

Comments

TANSTAAFL
In freebie/cheapie land, I got my air compressor, nailgun, and associated accessories for $150, because it was at a discount place and it was factory refurbished. Normally, the stuff purchased separately would be around $400.
March 30, 2007 01:23 PM
Trapper Zoid
I've heard fantastic things about Adobe Illustrator, but it costs as much as my PC. I'm not sure if the extra productivity would be worth shelling out the big bucks, or it would be a better use of my time to try and master Inkscape.

And then there's Flash to consider too...
March 30, 2007 04:33 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement