Archive for January, 2007

Easy Fix to an Apparently Common FlashPaper 2 Issue

Monday, January 29th, 2007

FlashPaper 2 was arguably, at one point, a competitor with Adobe Acrobat.  I’m not suggesting this was Macromedia’s intent, back in the day — maybe it was, maybe it wasn’t — and now that Adobe owns the lot, the discussion is moot.  In a nutshell, FlashPaper 2 converts documents into PDFs (just like Acrobat does, but with far fewer options), and it also converts documents into SWFs that “read” like PDFs.  They can be paged, searched, printed, and so on.  Neat concept, nicely executed.  I wouldn’t say these SWFs have especially caught on, but that’s fine … I use FlashPaper 2 in certain cases, and because it’s so pared down, the app loads much quicker than Acrobat.  That makes it an easy choice for no-frills PDF conversion.

FlashPaper 2 is available both as a stand-alone product and bundled with Studio 8.  On Windows, the Studio 8 version suffers a technical issue, apparently fairly common, in that it fails when used as a printer (as in, File > Print, and choose FlashPaper 2 as the print device).  Sure enough, when I re-installed Studio 8 after a recent hardware issue (completely unrelated), I could no longer create FlashPaper SWFs by printing to the app.  Keep reading »

The Displacement Map Filter Demystified

Friday, January 26th, 2007
ActionScript 2.0

Flash Professional 8 introduced a number of exciting new visual filters — such as drop shadow, blur, glow, and bevel — which reproduce many of the corresponding filters of Photoshop and Fireworks.  Of these, most are available via the Property inspector’s Filters tab.  All filters are accessible to ActionScript, but a few actually require programming.  One of these is the DisplacementMapFilter class, which distorts images based on the colors or transparency in a special reference map.

I just started a new article series on Community MX to explain the displacement map filter in visual terms.  My intent is to illuminate the somewhat overwhelming sample code provided in the ActionScript 2.0 Language Reference.  The first article is free content, and teaches what the DisplacementMapFilter class is and how to use it to reposition pixels in an imported graphic file.  In future installments, you will learn how to produce a handful of very cool visual effects that are only possible with ActionScript, including a magnifying class, fisheye lens, and ripples.

Sound.position “Gotcha” with Multiple Calls to Sound.loadSound()

Tuesday, January 23rd, 2007
ActionScript 2.0

The Sound.position property indicates how far along a Sound instance has played.  If you’ve loaded an external file or attached an embedded file at runtime, but haven’t yet started it, that instance’s position property is 0.  If it’s a 10-second clip and you’re 2.5 seconds in, the property reads 2500 (that’s 2,500 milliseconds).  When your audio reaches its end, position will match that instance’s Sound.duration property, which indicates the total length of the audio.  This is a can be useful for checking when a sound has concluded — of course, the Sound.onSoundComplete event is much more straightforward — but there are any number of reasons you might want to keep tabs on a sound’s position.  Unfortunately, this property doesn’t always report the value you may expect.  Keep reading »

Troubleshooting Tales:  The Case of the Mysterious Array.sortOn() Call

Friday, January 19th, 2007
ActionScript 2.0

Not long ago, I wrote an article for the Adobe Dev Center on handling cue points for external audio files.  The article shows how to extend the native Sound class in ActionScript 2.0 and 3.0 to add support for a custom cuePoint event.  In my SoundSynch.addCuePoint() method, I used Array.sortOn() to assure the growing list of cue points stays in chronological order.  Here’s a quick look at the AS2 version:

// Add Cue Point
public function addCuePoint(cuePointName:String,
  cuePointTime:Number):Void {
      type: "cuePoint",
      name: cuePointName,
      time: cuePointTime,
      target: this
  _cuePoints.sortOn("time", Array.NUMERIC);

The Array.sortOn() method accepts two parameters:  first, the name of the property on which to sort; second, and this is optional, the manner in which to sort.  In this case, I wanted to sort numerically, so I specified Array.NUMERIC.  Now, it gets fun.  Keep reading »

setTimeout() “Gotcha” in Class Files

Tuesday, January 16th, 2007
ActionScript 2.0

The setTimeout() function is a valid citizen in the realm of ActionScript 2.0; it was simply left off the roster for some reason, so you won’t find it in the documentation.  It works very much like its JavaScript counterpart and is less cumbersome to use than setInterval() for triggering a single delayed action.  You can reference setTimeout() just fine in timeline code, but I found an unexpected problem when employing this function in a class file.  Its presence halted the compile process and caused all sorts of misleading errors, such as the idea that Stage can’t be reference in a class file (it certainly can).  Is there a workaround?  Yes.  Keep reading »

Easy Brightness Adjustment with Color Panel’s HSB Mode

Sunday, January 14th, 2007

For things like highlights and shadows, I often find that I need a slightly lighter or darker version of my current color in Flash.  Until I knew about the Color panel’s HSB mode, I would either use the right-hand slider, even though it actually changes both brightness and saturation, or multitask over to Photoshop.  Sometimes I would just guess.

Figure 1, Color panel brightness/saturation combo slider
Figure 1 Color panel brightness/saturation combo slider

As it turns out, the Color panel’s context menu gives you precise, distinct sliders for hue, saturation, and brightness.  You simply have to toggle it them on.  (This may only refer to the Windows edition of Flash.)  Keep reading »

A Tip on the Boolean() Function (Casting as Boolean)

Tuesday, January 9th, 2007
ActionScript 2.0

When you load data from XML or text files, or retrieve values from the TextField.text property, the information you get is a string.  Even if the incoming value is, say, the numeral 3 (without quotes), it’s a string when evaluated by ActionScript.  Even if the value is “false” (with or without quotes), it’s a string — not a Boolean — and may appear to ActionScript as true!  Whoa!  That could cause a few problems.  In the case of numbers, there’s an easy way to tell ActionScript what the datatype should be, and it’s called casting.  You may cast a string numeral into an actual Number datatype by using the Number() function.  With a text field whose instance name is money

var looseChange:Number = 0;
looseChange = Number(money.text);

That converts the value of the money.text property to a true number, which you can verify with trace(typeof(looseChange)); — but the Boolean() function handles things differently.  Keep reading »

Simplify:  Use Boolean Expressions Creatively

Wednesday, January 3rd, 2007
ActionScript 2.0

I was coding up a slideshow this afternoon for a quick demonstration to a client.  In the end, much of today’s “rough draft” ActionScript will be converted into a custom SlideManager class.  For the time being, though, my “jump in and throw something together” approach was helpful anyway, because it brought to mind a number of features the client is going to ask about — I’d bet money on it — and now I’ll be prepared.  In addition, it reminded me of an admirable principle in programming:  elegance.  Keep reading »

Bad Haircut

Monday, January 1st, 2007
Flash General

Happy New Year, folks!

2006 was truly a good one.  I’ll be sharing some personal reactions in the coming weeks, including my feelings on what it’s like to break away from a salaried position (hint, I wouldn’t change it for the world, but wow … it’s been tough!).  Of course, I also have a bunch of new articles in the works on Flash, ActionScript, and whatever else seems useful.  I’ve been taking notes when people leave comments, so a number of future entries will be “by request.”

The last several months have been insane, schedule-wise.  I know I’m not alone — it’s been that way for almost every one of my friends, and for all of my colleagues.  I haven’t made a serious New Year’s resolution in … well, in years — but 2007 is different.  This year, I resolve to spend more time with my family, period.  That’s the main reason I decided to go full time freelance in the first place.  (Heh, I was about to say, “Wish me luck,” but in this case there’s no luck involved.  It’s a decision.)

A good friend of mine, Tom Green, recently had a Flash tech reference published by friends of ED.  He co-authored this one with Tiago Dias, From After Effects to Flash:  Poetry in Motion Graphics.  Tom’s got a great way with words; this is sure to be another useful volume.  Check out the sample chapter PDF from friends of ED.  See that handsome mug on pages 4, 37, and 38?  Yup, yours truly.  ;)   Thanks for inviting me to join the fun, Tom!