Thursday, June 19, 2008

Pulse of the Geek Nation

You saw it on Adobe TV, now you can see it in code....

Here is the running demo and source code for the Pulse application seen on the Developer channel of Adobe TV.

Rather than spend time here reiterating on what I said on the video, I'll just refer you to the video to get the motivation for the effect as well as the code walkthrough.

The Video

In case you didn't manage to make it to Adobe TV, here's the video presentation for Pulse:

The Demo

And here's the running demo itself:

The Code

And finally, here's the source code. I'm tempted to put snippets of the source code inline and go over them, but I would be basically duplicating what I already did in the video, so watch the video instead.

Thanks to Romain Guy for the original (Java) version of the demo, which he wrote for our book.

4 comments:

Jim Adams said...

I was wondering how you would set this up in a dynamic situation. Say I have something that creates a bunch of labels in ActionScript but I want some of them to glow. How would I add the effect to some of those labels?

Jim Adams said...

By the way, I really like these blogs!

Chet Haase said...

jim: Glad you're enjoying the blogs; I'll try to keep them coming. For glowing labels (or anything), you can take a similar approach of creating a subclass of whatever component you wish to glow, just like I did with GlowImage. Then attach an appropriate Blur filter to that instance and animate the alpha property of the filter over time, exactly as GlowImage does.

In fact, the only reason you need any subclass or custom code for your component whatsoever, as opposed to just attaching a filter directly to the Label (or other standard component) instance is that you need to reset the filters property on the component once the filter's properties have changed. That's the only reason I implemented GlowImage, and the only reason you'd need a subclass for other components you wish to pulsate.

Jim Adams said...

I was thinking mostly of the ActionScript methods of adding the effect than the mxml methods. I was able to create a GlowLabel component and have it glow under certain conditions. The GlowLabel was created as a subcomponent of another component which is why I was looking for ActionScript methods. But, like I said, I got that working.