Archive for February, 2007

The VideoPlayer Class API (aka, the Missing Manual)

Tuesday, February 27th, 2007
ActionScript 2.0 Quick Tips

I was just gabbing with someone about the NetStream class, which nudged my mind toward the VideoPlayer class.  According to the Components Language Reference, the FLVPlayback class “extends the MovieClip class and wraps a VideoPlayer object.”  As it turns out, the VideoPlayer class is mentioned in the Components Langauge Reference, but if you dig into it, you’ll quickly discover that none of the class members is hyperlinked.  In other words, you’ll get an overview of the properties, methods, and events defined by that class, but no actual explanation.

I find that an odd omission — but Adobe does make the full API available.  Keep reading »

Loading and Tracking Multiple Files at the Same Time (Part 1)

Sunday, February 25th, 2007
ActionScript 2.0

Not long ago, a blog guest entered into conversation with me about loading and tracking multiple files at the same time (see Event Handlers versus Event Listeners comments, starting with the eighth comment).  Tiemen was hoping for a way to use the MovieClipLoader class inside a custom ActionScript 2.0 class, not only to load external files — which isn’t especially difficult — but also to track each file individually; that is, to be able to pass individual functions into the custom class, and have that class manage the tedium of assigning the passed-in functions to the MovieClipLoader events of each file.  This particular requirement was the tricky part.  If the custom class merely had to manage event handlers for a single MovieClipLoader instance, that would be easy.  (In fact, this is completely possible.  Be aware, if you choose to read the other entry’s comments, I mistakenly believed at the time that the events of a single MovieClipLoader instance were not capable of providing useful information for more than one loading file at a time.  I’ve noted those errors in my replies.)  Because Tiemen wanted the ability to assign separate functions for each file’s events, well … that meant maintaining an array of MovieClipLoader instances.  Let’s take a look at one way to accomplish this goal.  Keep reading »

Code Hinting Regardless of Naming Conventions

Wednesday, February 21st, 2007
ActionScript 2.0 Quick Tips

Depending on my mood, I may precede certain variable names with a small prefix that describes the type of object they point to.  For example, I may give a movie clip the instance name mcBall, rather than just ball.  Why?  Well, it allows me to see at a glance that I’m dealing with a MovieClip instance, which can come in handy during coding and also while I’m poking through the Debugger panel.  It doesn’t have any measurable effect on the functionality of the variable … it’s just one of those things you get used to.  I certainly don’t always adhere to this convention, but when I do, I’m practicing something called Hungarian notation, which has a decent pedigree (at least, in computer years).

Flash provides at least one naming convention that actually can make a practical difference, if you follow the suggested suffixes in the “About using suffixes to trigger code hints” section of Learning ActionScript 2.0 in Flash.  I’m not especially a fan stylistically, but, for example, if I name that ball clip ball_mc, I’ll get automatic code hinting for the MovieClip class (and so will you) in ActionScript 1.0 and 2.0.  A full list of suffixes is listed in that section.  Code hinting is definitely a useful tool, because I’m not always familiar with the class members of the object at hand.

What if you don’t like suffixes?  Or prefixes, for that matter?  Well, if you use AS2’s strong typing syntax (the :Number in something like var total:Number = 5;), it doesn’t matter what you name your variable:  you’ll get code hinting if you want it (see File > Preferences > ActionScript).  That’s fine for everything but movie clip instance names, which aren’t necessarily declared as variables.  But … see, if you declare instance names anyway — even though you don’t need to — you get the benefit of code hinting regardless of the instance name.

With a simple line like this …

var ball:MovieClip;

… even though you haven’t set that instance to anything, you’ll get MovieClip-centric code hints for subsequent references to that instance name in your code.

updateAfterEvent() … What’s the Scoop?

Monday, February 19th, 2007
ActionScript 2.0

Someone asked me the other day, “What’s the deal with updateAfterEvent()?  What, exactly, does it do, and when should it be used?”  Well, I’m a fan of the ActionScript 2.0 Language Reference, so my usual reply is along the lines of, “Let’s check out what the ASLR has to say,” but in this case, the documentation doesn’t speak the whole truth.  Keep reading »

Recognizing Audio Patterns Visually

Saturday, February 10th, 2007

I’m working on a whopping slideshow for a big client.  The fun part, unfortunately, is pretty much behind me.  The framework has been built.  At this point, I’m merely a slide-crunching machine.  There are hundreds of slides.  This partly explains my sporadic blogging in recent weeks.

Things I’ve come to realize:  a) more than ever, I’m thankful for JSFL (particularly, its File API), which allows me to make automated changes to all my slides at once; b) when I deal with audio files in Audition often enough, I begin to “see” recurring spoken phrases in the waveform — which is a bit like that dude in The Matrix who “sees” blondes, brunettes, and redheads in the tumbling data characters.  Keep reading »