My First Flash Program

Posted at

Yesterday afternoon, Chava called me up and asked me if I could change her Web site so that a sample song would start playing as soon as someone visited the site. I figured that the best and easiest way to do this would be to create a Flash applet, and it seems I was right.

Some googling around turned up a lot of possibilities for software that I could use to author this little snippet, but I fell in love with the swftools suite as soon as I discovered it. The centerpiece of this tool set is the compiler for the tiny little scripting language that the authors cooked up for describing the actions possible in a Flash animation. This simple language makes easy things easy, as attested by the fact that I was able to whip up a solution to my problem in just a few hours and in a hair under a kilobyte of code, despite the fact that I'd never even thought about creating Flash before. And most of those hours were spent hunting down a decent reference guide for ActionScript (since the documentation provided by Macromedia seems to go out of its way to be as useless as possible for anyone who isn't using their overpriced authoring application).

Picking up ActionScript itself was surprisingly easy. ActionScript is the language used for programming how a Flash animation reacts to user input. It's just like JavaScript, but set in the context of a different library of classes and objects. And even though I don't think I've ever spent more than 30 minutes cumulatively over the course of my life purposely learning about JavaScript, I seem to have picked up everything I need to know about it by osmosis.

The truth is, I could have put even less effort into this micro-project than I did. One of the programs in swftools lets you convert a sound file into a Flash file in one trivial step. I could have simply embedded the resulting Flash file into Chava's site and the desired music would have started playing quite plainly. But then a person viewing the site would have no convenient way of turning off the music without leaving the site, and I certainly would not tolerate such inconsiderate behavior from any Web page that I visit. To tell the truth, I'm not certain that playing music on the audience's computers without any warning is the most polite thing to do anyway. After all, people visiting the site might be in an environment where they'd prefer to keep quiet, or they might already be listening to something and they wouldn't welcome the intrusion of an unexpected song. I'm going to ask Chava if it wouldn't be a better idea to default to leaving this background music off until the user specifically turns it on by clicking on the relevant button.

In any case, you're welcome to help me test out this little creation before it goes live. I'm open to any feedback you might have.


Comments

Comment from jeff covey at

it worked, but took so long to load that i probably would have already left the site before it started playing.

Comment from Daniel at

As I suspected, my miniscule upload bandwidth is
probably going to be the achilles heel of this
little endeavor.

Comment from Abba at

I tried to test your "little creation," but nothing happened.  I got sent to a blank screen and it just sat there.  Ah, well . . .

Comment from Abba at

Reading Jeff's comment now, maybe I didn't wait long enough for something to materialize.  I did wait at least a minute, tho, and I saw no sign that anything was about to happen.  Maybe I'll try again later.