Debugging ActionScript 2.0 Code:  Lifting the Blindfold

Flash ActionScript 2.0

There are innumerable things to enjoy in MGM’s The Wizard of Oz, not the least of which is a valuable lesson learned:  “If I ever go looking for my heart’s desire again, I won’t look any further than my own back yard,” as spoken by Dorothy near the conclusion.  In the Flash world — in fact, in development or programming of any kind — this can be applied to the concept of reading the documentation, as illustrated in my recent Community MX article, “Tackling the ActionScript 2.0 Language Reference.”

But there’s more to it than that.  Next to studying the docs, you’ll need another indispensable skill:  debugging.  This is especially true when dealing with ActionScript.

I’m pleased to announce that Adobe has accepted an article I wrote on this topic, recently published in their Developer Center.

http://www.adobe.com/devnet/flash/articles/debugging_actionscript.html

I’d like to thank Chris Georgenes, Stefan Gruenwedel, Jen deHaan, and Michael Koch for providing valuable input, feedback, and encouragement along the way.  Special thanks to Branden Hall for giving me kind permission to put an ActionScript 2.0 gloss on one of his custom functions, originally published in his and Samuel Wan’s Object-Oriented Programming with ActionScript.

8 Responses to “Debugging ActionScript 2.0 Code:  Lifting the Blindfold”

  1. ImagicDigital Says:

    Congrats on a great article! There’s a ton of info in it, but very well organized, and — of course — made interesting with good writing. I like the fact that it was so well illustrated with screenshots (allows the reader to follow along even without opening up your sample files). Which I will download anyway, to get at the traceXML function you mention above! ;)

  2. David Stiller Says:

    Thanks, ImagicDigital! I owe thanks to Jen deHaan for many of those screenshots. She was great about eliciting more and more detail from me.

  3. NSurveyor Says:

    You know, I’ve never actually used the Debugger panel. And now I can see how useful it really is… guess it’s time to start using it!

    Also, aren’t there 257 levels of transparency?

    MovieClip.prototype.addProperty(’_alpha256′, function () {
    return this._alpha/100*256;
    }, function (x) {
    this._alpha = x/256*100;
    });
    _alpha256 = 0;
    trace(_alpha256);
    _alpha256 = 128;
    trace(_alpha256);
    _alpha256 = 256;
    trace(_alpha256);

    0-256 is 257 values.

    See this Adobe forum thread (via Google Groups).

  4. David Stiller Says:

    NSurveyor,

    Flash only supports 256 levels of transparency, but your experiment is very interesting (as usual!). :) In Flash, the range goes from 0 to 255, which is 256 values; in your math equation, the range goes from 1 to 256, which is, again, 256 values.

  5. NSurveyor Says:

    How so? The way I see it, the minimum value for my above code is 0. The maximum is 256. That gives 257 values? I don’t see how the minimum value is 1 (according to my code)???

  6. David Stiller Says:

    The more I think about it, the less confident I feel about my original reply, NSurveyor. ;) This reminds me of the classic “missing dollar”/hotel puzzle, which always seems to stump me when I haven’t re-read it in a while. If you figure it out, let me know! :)

  7. NSurveyor Says:

    Did a little digging into the newsgroups… and haha, I found this:

    Jeckyl:

    “alpha values are always a multiple of 100/256 .. because inside the flash
    player, alpha values range 0..256. So there is no exact 10% value.”

    So there are indeed 257 values, because Jeckyl is almost never wrong… :)

    See this Adobe forum thread (via Google Groups).

  8. David Stiller Says:

    Jeckyl would know, for sure. Always something to keep learning in Flash!

Leave a Reply