Viewing the ‘Flex’ Category


Flex 4 with a Hint of AIR 2

02.04.2010

Here’s my presentation from today’s training at Rain entitled Flex 4 with a Hint of AIR 2. Enjoy!


Finding nodes with a namespaced attribute using e4x

12.19.2009

When digging through XML, e4x is definitely your friend but it can be tricky sometimes. I recently came across a situation where I needed to find all nodes with a certain namespaced attribute. I didn’t care what the attribute’s value was; I just needed to know which nodes had the attribute. Continue reading »


Showing Progress for Multiple Loaders

10.17.2009

A common thing to do in most any rich application is to show progress while loading remote assets. In ActionScript, the bytesLoaded and bytesTotal properties of classes such as LoaderInfo and URLLoader provide the needed information to show a fancy percentage-based progress indicator. The bytesLoaded property is updated as more and more of the asset is loaded in. Divide that by the bytesTotal and you have the percentage loaded.

Easy enough. How about multiple loaders? Lets say you have a group of 10 images and you’d like to show progress for all the images collectively. Because you have 10 different images you also have 10 different URLLoader instances (or Loader instances, whatever suits your fancy)–one for each image. Math would say that you divide the sum of bytesLoaded by the sum of bytesTotal and that gives you the percentage complete. Two issues arise: Continue reading »


Piano Marvel: Interactive Piano Lessons

09.02.2009

Rain, where I work, has released yet another super-duper app. It’s called Piano Marvel and it’s set to revolutionize how people learn how to play the piano. I’m not a piano player myself, but I do remember taking private piano lessons as a kid. I hated it. It was monotonous, inconvenient, and felt like a chore. I wasn’t intrigued and I don’t believe I was the only kid that felt this way.

A while back, Guitar Hero hit the gaming industry by storm and kids flocked to learning the guitar. Sure, it wasn’t a real guitar, but it was still an instrument of sorts and kids were still learning hand-eye-ear coordination, rhythm, and other music essentials. The game was a huge success, bringing in over $1 billion in sales in the first 26 months and set an industry record.

Why such a difference in my experience learning how to play the piano years ago and kids learning the pseudo-guitar with Guitar Hero? Guitar Hero provides objectivity, benchmarking, competition, and addiction. You can play with your friends in a fun atmosphere. Piano Marvel takes these concepts and applies them to learning the piano. Students play along to accompaniment, see exactly which notes they hit and when they hit them, and earn trophies as they complete increasingly difficult exercises. They can practice whenever they choose and can even battle it out with their piano-playing comrades. Continue reading »


Skinnable Knob Component

08.23.2009

Recently I went searching for Flex knob components on the web and found they either weren’t equipped for my needs or closed source. So, I cooked up my own knob (or dial) component that hopefully someone out there can use. Go do something cool with it. Continue reading »


Loading a Remote Module into a Local App

08.14.2009

At work, we deal a lot with loading modules residing on remote servers into our applications running locally.  By locally I mean from a local path on our hard drives (the default Flex Builder run/debug settings), not on a local web server instance (localhost).  Depending on what type of module we are loading, we would normally use one of Flex’s built-in functions to load modules:

// Loading a language resource module:
resourceManager.loadResourceModule('http://aaronhardy.com/en_US_ResourceModule.swf');
 
// Loading a style module (e.g., a compiled font swf):
StyleManager.loadStyleDeclarations("http://aaronhardy.com/fonts/Astroid.swf");
 
// Loading miscellaneous modules:
var moduleInfo:IModuleInfo = ModuleManager.getModule('http://aaronhardy.com/MyModule.swf');
moduleInfo.load();

But these methods of importing modules result in errors like the following:

Unable to load resource module from http://aaronhardy.com/en_US_ResourceModule.swf
Error: Unable to load style(SWF is not a loadable module): http://aaronhardy.com/fonts/Astroid.swf.

Continue reading »


Rain SVG

07.03.2009

Businesses win customers when they deliver what customers want. Customers get what they want when they can customize products to their own preferences. At Rain, where I work, we recognize the profit potential that clients can achieve with this concept and have created many applications allowing users to design their own products. How do we do it? Let’s talk SVG.

Suppose we create a simple product designer containing a single rectangle. The user can rotate, scale, position, and color the rectangle. The rectangle will then be printed in spectacular fashion on the customer’s very own poster. So, Jim hops into the application and moves the rectangle to the center of the poster, doubles its size, colors it blue, then rotates it 45 degrees. He then saves his design.

How is Jim’s design saved? That is, how is Jim’s design described in such a way that (1) he can later re-open it and continue modifying his rectangle and (2) a printing shop can print his poster at virtually any size without degrading its quality? Continue reading »


Image Repeater

05.15.2009

Some things that should be super-easy and straightforward in Flex just aren’t. Repeating an image is one of those. It’s not super-difficult, but I can see how a newcomer could be easily turned off because it isn’t just a simple style like in CSS.

Every time I google for a simple component to give me image repeating functionality, I always turn up components that are overkill for my needs or have weird quirks. I realize I’m just throwing another hat into the ring here, but I decided to cook up a simple image repeater component that just has one goal in mind: repeat an image. It’s not a container or anything like that. It just repeats an image. That’s it. See it in action here and right-click for the source.


TileList Padding and Grid Lines

05.14.2009

As you might know, designers can come up with some pretty funky ideas that don’t always match up with the default functionality of the framework you’re using. The pro is that your app turns out fresh and unique. The bad is that you’re the one that has to make it work. Of course, that also might be why you have a job.

Recently I received a comp from a designer that looked more or less like this:

Grid TileList Continue reading »


Nimbus – Macro Commands

04.29.2009

In my recent intro to Nimbus, I mentioned that one of the features of Nimbus is macro commands. In complex applications, macro commands can be a huge time saver and allow you to have a lot of control over handling a group of service calls with minimal code.

Two types of macro commands exist. The first is a SequenceCommand. This means its subcommands will be executed sequentially. In other words, the second subcommand won’t begin executing until the first subcommand has finished executing. The SequenceCommand won’t be considered complete until the last subcommand has finished executing.

The other type of macro command is a ParallelCommand. As you may have guessed, this means its subcommands will be executed in parallel. In other words, the first command and second command will execute at the same time. The ParallelCommand won’t be considered complete until all subcommands have finished executing.

Just as the synergy of the Planeteers can work miracles, so can the synergy of the SequenceCommand and ParallelCommand. Nesting macro commands can give some enhanced control as we’ll see here: Continue reading »