Archive for the ‘ActionScript’ Category

I saw this effect a long time ago, and wanted to use it in a project, but after about ten minutes of searching for the original, I gave up and just decided to make my own.

waterfall.png

Click on the image above to view it in action.

This is just a basic bitmap effect that uses BitmapData to draw an image, with the pixels spilling down from the top in a waterfall-type effect. The fun thing about this is that since the source of the effect needs to implement IBitmapDrawable, you can supply just about anything as the source. In the example below, select “This Panel” to watch the options panel be redrawn. The end effect is that each individual piece of the panel is “beamed down” on it’s own. The “Flow” image is another favorite of mine.

The ’speed’ option is simply the number of milliseconds used in the Timer to execute the effect.

Source is also provided, just right-click on the example to get it.

By now you’ve seen and heard plenty about Flash Player 10. One feature that I’m in love with right now is the new text rendering provided by Saffron 3.1. Among other things, this provides better anti-aliasing for fonts, including device fonts.

Why does this matter? Because now you can use device fonts in your TextFields, and do things like adjust their opacity, or rotate them without needing to embed the font. How sexy is that? Obviously, if you’re using a custom font, you’ll need to embed that, but for device fonts, it’s no longer a requirement just to adjust the alpha value of a TextField.

Check this out (You’ll need Flash Player 10 installed).

Download the source: AstroTest.as.

This is a really simple demo, but it’s enough to get the point across.

There have been plenty of times in projects where I’ve wanted to compare two objects to see if they are equal. I don’t really care if they are the same object, all I care about is if they are identical - meaning that they could be two unique objects, but that the values of their properties are equal to each other.

Read the rest of this entry »

Sure, there are several places out there where you’ll find this information, but nothing really in an easy-to-print form you could hang on your cube wall.

This list is far from comprehensive, but it’s a list of the ones I use most often, and find the most useful. There’s a reason I made the first one on the list “View all Shortcuts”.

As I’m a Mac user, the shortcuts are for the Mac version of Flex Builder, but I would assume that you Windows folks can just use Ctrl instead of the Command key.

Here’s a nice PDF, ready for printing: FlexBuilderShortcuts_MAC.pdf

If there’s something you really feel strongly about me having left off of the list, let me know in the comments, and I’ll add it to the list.

If you’re a Flex dev, and haven’t checked out FlexExamples, you need to.

Run by Peter deHaan, each day he posts several simple code examples ranging from skinning components to manipulating Strings. The great thing is that each example is fairly short, and to the point. No long-winded explanations, just a short explanation, followed by sample code.

How is Peter stalking me? For the last two weeks, it seems like every time I run into an issue with my code where I’m stumped, and am having problems finding a solution online, within about 15 minutes my RSS reader pops up with a new post from Peter, that contains the solution to my problem.

Seriously Peter, where are you hiding? My cube isn’t that big.

For a new AIR project I’ve been working on I wanted to include a chromatic tuner as a feature. That would be awesome, right?

While working on this feature, I’ve been doing some research into how exactly you even go about determining pitch using code, and have been playing with the SoundMixer.computeSpectrum() method lately. Unfortunately, that’s not looking like it’s going to be a possibility, as apparently the sound info from a microphone or line input isn’t available to the SoundMixer.

From the liveDocs

Because sound data from a microphone or from RTMP streams do not pass through the global SoundMixer object, the SoundMixer.computeSpectrum() method will not return data from those sources.

Bummer.

Hopefully this can be changed in future versions of the Flash Player.

The global trace() function is probably the simplest, and most useful methods of debugging that ActionScript developers have. Usually, it's used to output the value of a variable or to broadcast out a little note that some event occurred. Most people use it something like this:

  1. trace ("myVar: " + myVar); // outputs value of myVar
  2.  
  3. if (somethingGood) {
  4.         trace ("something good just happened!");
  5. } else {
  6.         trace ("Houston, we have a problem!");
  7. }

Well, now in AS 3.0, trace() has been modified to allow multiple parameters! What's so cool about that? Well...

Instead of this:

  1. trace ("user name: " + lastName + ", " + firstName);

you can do this:

  1. trace ("user name:", lastName, firstName);

Or, simply output a list of variables all at once instead of using multiple trace() calls:

  1. trace (address1, city, state, zip);

Not exactly earth shattering, but it's definitely a welcome addition to ActionScript.

Sure, it's from last year, but I just found it the other day, and I love it. David Zuckerman has compiled a short list of shortcut keys in Flex Builder 2 that you should check out if you work with Flex Builder.

It's by no means a comprehensive list, but there's some good stuff in there. The "Quick Outliner" has already saved me a bunch of time, and the "Organize Imports" feature is great as well.

Link: http://davidzuckerman.com/adobe/2006/10/27/flex-builder-editor-cheat-sheet/

If you're an obsessive trace() statement user like I am, and you happen to use Eclipse for your ActionScript coding, you're going to love the LogWatcher plugin.

http://graysky.sourceforge.net/

If you have your Flash Player setup to log trace() statements and other errors to a text file, just point LogWatcher to the location of your Flash log text file. Even when testing from the Flash IDE, this text file will still be updated, and LogWatcher will pickup the changes. Essentially, you now have a duplicate of Flash's Output Panel in Eclipse. You'll no longer need to switch between Eclipse & Flash just to see what you happened to trace out when trying to debug something. I'm not sure how it works on Windows, but on OSX, if Flash isn't in focus, then all of the panels disappear - meaning that you can't look at your Output Panel and your code in Eclipse at the same time.

LogWatcher also includes the ability to set filters, to make it easier to find what you're looking for. Need to find a single line in a sea of other trace output? Just create a filter, and let LogWatcher color that line red for you each time it appears.

ActionScript 3.0 Cookbook Cover

Book Details:

  • ActionScript 3.0 Cookbook
  • Joey Lott, Darron Schall, & Keith Peters
  • O'Reilly Media, Inc.
  • List: $39.99 Amazon.com: $26.39
  • ISBN: 0-596-52695-4
  • 556 Pages

By now, most Flash developers know that ActionScript 3.0 is a huge improvement over ActionScript 1.0 & 2.0. These improvements come in the form of faster performance, enhanced features, and the general awesomeness that comes with using the AVM 2 in Flash Player 9.

However, one of the biggest hurdles in using AS 3.0 is learning it. There are many similarities between AS 2.0 & AS 3.0, but for all the similarities, there are plenty of differences. If you're an experienced Flash developer, fluent in AS 2.0, you'll be able to pick up AS 3.0 fairly easily. The biggest trick, (at least for me) is learning the new way to do things in AS 3.0 that have become second nature in AS 2.0. And that's where the ActionScript 3.0 Cookbook comes in.

Read the rest of this entry »

Entries (RSS) Comments (RSS)