Posted in March 2007

Order of Operations Strikes Again

by

Quick AS3 hint for today. Keep learning from my mistakes! Did you know that the order of the ! operator is higher than the order of the is operator? That means that in the example:

if (!strategy is AwesomeStrategy) {...

in which I am trying to run some code if the strategy is not an instance of AwesomeStrategy, actually evaluates:

if (null is AwesomeStrategy) {...
if (false) {...

In other words, the not binds higher and applies to strategy instead of strategy is AwesomeStrategy, the condition evaluates to false 100% of the time, and you end up puzzled as to why the block in the if statement didn’t run. Don’t make my mistake! Include parentheses when negating comparisons! Use this instead:

if (!(strategy is AwesomeStrategy)) {...

That’s right, you heard it here first. Unless you aren’t as tired as me right now and already knew that. Actually, as I look at my incorrect code now, it seems pretty obviously incorrect. OH WELL!

See the whole order of operations in AS3 here.

Apollo Tip: Never See the Flex Loader

by

Here’s a really simple trick you can use to prevent the Flex loader from showing when you start up your application. All you have to do is hide the window, and show it when the Application is ready.

In MyApplication-app.xml:
<rootContent systemChrome="standard" transparent="false" visible="false">[SWF reference is generated]</rootContent>

This sets your application manifest to make the root window invisible. Then, you just make it visible when everything’s ready:

In MyApplication.mxml:
<mx:MyApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="window.visible = true"> ...

Easy peasy!

Using E4X With XHTML? Watch Your Namespaces!

by

One of the best things about AS3 so far, for me, is the decision to make it much noisier about failing. If there was one thing that was frustrating before, it was trying to track down what failed silently and where, only seeing the effects far downstream, with a barely workable debugger. Things are sooo much better now.

Nonetheless! There are always going to be little things that trip up every new programmer until you learn them, or maybe that trip you up over and over because it’s just so hard to remember. Certainly there will be less of these in AS3, but new is exciting, right? Ok, so enough intro. I post stupid mistakes. You learn from my mistakes. Somewhere, an old woman makes waffles. Read on.

Continue reading

Tech Writing Tips

by

As you may know, Roger and I are working on the next version of the ActionScript Bible published by Wiley (the Amazon page is full of errors, don’t worry, it’s not even out yet). I wanted to share a few tips that I use as notes to myself for when I’m stuck with writing.

  • Write headlines and use the outline view to order the big picture
  • Simplify
  • Base information around a task that the reader might want to do
  • Write or flow without being concerned about the form then go back and edit it later
  • Ask “Do I really need this?”
  • Read other similar books
  • Say it out loud then write down what you say
  • Work on something that you know you can finish then go back to where you were stuck
  • Forget about style and focus on the facts
  • Take breaks and do something different like drawing a diagram or writing a code sample

Aliased Text in Eclipse on OS X

by

Maybe I’m just a crotchety, old-school, Jolt-drinking, amber-on-black, command-line code junkie, but for the last 2 years I’ve been so frustrated that I just can’t get my code font in Eclipse / Flex Builder on Mac OS X to be aliased! Those little smooth edges on my fixed-width bitmap fonts drove me to irrational madness. Well, I had given up and moved to PC, but I’ve had Mac laptops throughout, and I finally took some time to solve this little pet peeve. If you share my frustration, read on.

BeforeArrrgh!

AfterAhhhh…

Continue reading

Tagged