Archive for August, 2006

Unexpected “Gotcha” with Relative Paths in ActionScript

Friday, August 25th, 2006
ActionScript 2.0 Flash

About a month ago, I mentioned a quirky fact of life when dealing with relative paths in ActionScript.  In a nutshell, a SWF’s point of view changes depending on how it’s embedded.  A SWF considers relative paths from its own folder when played in a Projector.  That makes perfect sense.  On the other hand, a SWF embedded in an HTML document, as played by the Flash Player plug-in, sees things differently.  To a SWF in an HTML document, relative paths begin from the folder of the HTML document.

For example, if a root HTML document embeds a SWF in a flashcontent subfolder, and if that SWF loads a JPG from the same folder as itself, the ActionScript must nevertheless include a reference to the flashcontent subfolder — because that’s where that JPG is located from the HTML’s point of view.  This can quickly confuse matters when you test the SWF from inside Flash, because the Flash IDE plays SWFs inside a special Projector (see (Perhaps) Unexpected Point of View:  SWF Defers to HTML for some workarounds).

That’s a “gotcha” enough already, but I just discovered an exception to the rule.  Keep reading »

What Fonts are Common to Windows and Mac?

Tuesday, August 22nd, 2006
Web Development

Here’s a handy URL.  If you’ve ever asked yourself the above question — I sure have — the following site provides a useful breakdown.

Building a Drag-and-Drop Jigsaw Puzzle

Monday, August 21st, 2006
ActionScript 2.0 Flash

Here’s another freebie from Community MX.  I had a lot of fun with this one!  In this two-part series, I step the reader through an ActionScript 2.0 class that builds a jigsaw puzzle engine.  The complete code and sample files are included as a download with the tutorial — yes, even in Part 1, which is free.  Part 2 (published in a week or two) covers the second half of the code in detail and shows how to incorporate the puzzle into a more elaborate layout.

If this sort of content appeals to you, you may want to give Community MX a shot.  Plenty of content is free.  Other content is usually priced around $5 per article (give or take a few bucks).  The stuff is honestly inexpensive, and every article is peer-reviewed.  For a subscription, you get all-the-time access to over 1,700 articles, as of this writing.

The more time I spend with the CMX partners, the happier I am to have joined the team.  Good bunch of people.  :)

How to Drag Clock Hands in a Circle

Wednesday, August 16th, 2006
ActionScript 2.0

This one’s on request.  :)   Here’s a variation on How to Constrain Dragging to a Circle that’s different enough it merits its own entry.  Interestingly, this question crops up often enough in the forums.  Usually, someone is putting together a children’s game in which the child is expected to drag clock hands to the correct time.  As it turns out, this requires even less code than constraining dragging to a circle.  Let’s take a look.  Keep reading »

How to Tell a SWF What File(s) to Load — From the Outside

Sunday, August 13th, 2006
ActionScript 2.0 Flash

A number of people have asked how I handled the microphone icons in my last post, Papi’s Wah-feh (An Audio Guide).  Did I simply use Save As a bunch of times to create eight separate SWFs, each with its own imported audio?  I certainly could have done that, but I decided instead to create one single SWF that could be told from the outside which MP3 to play.  Not only does this mean I can re-use that SWF as often as I like — without recompiling, by the way! — but it also reduces download time, because the SWF is only retrieved once (only 407 bytes, at that!), and the MP3s only load as needed.

The following technique can be used for graphics, too — really, for any file a SWF can load at runtime, from CSS to video (FLV), to other SWFs.  Let’s take a look.  Keep reading »

Papi’s Wah-feh (An Audio Guide)

Tuesday, August 8th, 2006

This article contains clickable microphone icons.  Click to hear Meridian’s pronunciation of the associated terms, as recorded on Papi’s kleines Radio [Papi’s little radio].

I like Turkish coffee.  Dawn chides me jokingly that this zealous preference makes me a coffee snob — but that’s taking it too far.  I’ll happily drink whatever’s served when dining at a friend’s house.  I certainly don’t turn away a “cup of Joe” while on-site with a client.  But, see, there’s a difference between browsing a magazine at the airport and curling up in bed with one of the classics:  savoring something doesn’t make a person snooty.  ;)   Keep reading »

How to Constrain Dragging to an Ellipse

Monday, August 7th, 2006
ActionScript 2.0

In an earlier article, we briefly touched on the built-in MovieClip.startDrag() method, which allows dragging to be optionally constrained to a rectangle.  In that same article, we also looked at a way to constrain dragging to a circle, in which case dragging actually meant positioning the movie clip where the mouse was — as long as that area lay within an arbitrary circle.  Here, we will constrain dragging to an ellipse.  Keep reading »

How to Constrain Dragging to a Circle

Thursday, August 3rd, 2006
ActionScript 2.0

Garden variety movie clip dragging is easy to handle via the MovieClip.startDrag() and MovieClip.stopDrag() methods.  In fact, it’s even easy to constrain dragging to an arbitrary rectangular area.  Just invoke these methods when handling the clip’s MovieClip.onPress and MovieClip.onRelease events.

// Standard dragging
mc.onPress = function() {
mc.onRelease = function() {

// Constrained dragging
mc.onPress = function() {
  this.startDrag(true, 0, 0, 200, 100);
mc.onRelease = function() {

In that second example, the MovieClip.startDrag() method is supplied with optional arguments.  The first, a Boolean (true/false) determines whether the clip is dragged from its center or from the mouse’s position when the mouse first clicked.  The rest refer to coordinates of the clip’s parent.  If this clip is situated in the main timeline, the parent would be the main timeline.  In this case, the movie clip will only be draggable within a 200×100 pixel rectangle.

So, what if you want to constrain dragging to a circle?  Keep reading »

Need Filler Text?

Tuesday, August 1st, 2006
Quick Tips

It makes no difference if you’re laying out HTML, a word processing document, or even an image with lots of text.  If you need filler content, just so you can visualize the layout, give Lorem Ipsum a shot.  I use this site all the time.  It’s free.