Flex/Flash/Actionscript

Analyze your ActionScript code with this Apollo app

This is a little Apollo app I whipped up so I could analyze the Flex SDK source code. It analyzes actionscript code and produces some basic stats: number of files, breakdown of lines of code (comments versus whitespace versus real code), and it counts functions and variables. Not really useful for anything in real life, I was just curious how large the Flex SDK was, so I wanted a way to figure that out.

When it first loads it tries to locate the location of the Flex SDK source if it can find it on your computer. You can change that to scan whatever directory you want. Be aware it’s going to recursively loop over every subdirectory, and it you set it to scan your root folder it might hang for a while.

Oh, and a secret note: if you drag the bottom right corner of the app you can resize it.

So some stats just for fun:

Flex SDK: 287,661 lines of code
FlexLib: 17,885 lines of code
This Apollo app: 1,018 lines of code

Download the .air file here to install the Apollo app.

Some screenshots:
apolloapp1.jpg
apolloapp2.jpg
apolloapp3.jpg

Standard
Flex/Flash/Actionscript

There are 287,661 lines of code in the Flex 2 Framework SDK

I did a few calculations on the Flex SDK source code. By my count there are 788 files (.as or .mxml) for a total of 287,661 lines of code. Out of that, 87,216 lines are comments (about 30%).

The top 5 biggest classes are: UIComponent (8,407 lines), ListBase (7,414 lines), Container (5,056 lines), DataGrid (4,885 lines), and AxisRenderer (3,441 lines).

Why the hell did I figure this out? Well, I was preparing for my presentation about extending the Flex framework with custom components for tomorrow’s silvafug meeting, and I got curious just how much code there really was in the Flex Framework. If you’ve ever dug into the source code for the framework you know that there’s a lot there, dig deep enough and you’ll find some monster classes that must have taken a bazillion man-hours to write.

The totals above include every .as and .mxml file that is published in the SDK source. There are some classes that are intrinsic classes in the Flash Player, which were not written in Actionscript, and these are obviously not included in the count. Also not included are the Apollo component source files (in case you’re curious that’s another 9,100 lines of code).

I’ve put together an Apollo app that will scan the Flex SDK source directory and tell you these stats, along with breakdowns by class, so you can see wonderfully interesting things like how many private functions each class includes, or how many lines of whitespace are in each file. I’ll be releasing the Apollo app shortly that you can run on your own code. God knows why you’d want to. I guess this is what happens when I get curious, I make useless pieces of software. Woot woot.

Here’s a little screenshot of the Apollo app in action:
apolloapp2.jpg

Standard
Flex/Flash/Actionscript

Where have I been? Where am I going?

I haven’t been blogging too much recently, but I thought I’d do one of those “hey, I’m alive” blog posts, and also a put the word out that y’all should come to the silvafug meeting in SF in May and to 360 Flex in Seattle whenever that is. I’ll be speaking at both those things.

Traveling
I’m currently sitting under a thatched roof in El Salvador, somehow there’s a cat-5 jack coming out of the concrete table. Just got back from a trip into Guatemala, and soon I’m off to sail to Nicaragua or Costa Rica. I’ll get back to SF sometime around the first week of May. No Flex work while traveling, although I did consider bringing my new laptop to Central America.

Worst unemployed person ever
I became unemployed at the end of March, even had a sweet retirenement party to celebrate. Turns out I’m really bad at being unemployed and started doing contract work with Universal Mind for a few weeks. Part of me wanted to just sit back, relax, and forget about deadlines and paying work, but the project they got me working on was really interesting, I got to work with some great guys, and all in all had a blast. At least I managed to do most of the work in my bathrobe.

Silvafug and 360 Flex
I’ll be presenting at the silvafug meeting on March 10 in San Francisco. The session will be about custom component development, and Tom Ortega will be leading a training session on the same topic before my presentation. If you’re in the area, come on by Thursday night and tell me how wrong I am about whatever I’m talking about. And if anyone wants to go out for some drinks afterward, I’m always down.

I’ve also somehow managed to convince Tom that I know what I’m talking about (we’ll see if that changes after the silvafug meeting), so I’ll be speaking at 360 Flex in Seattle. I’ll be working out how that presentation will go over the next few months, but the topic will be similar to the silvafug session, basically how to fuck with the Flex framework classes to make the components that you actually want.

So come by the silvafug meeting on May 10 if you can make it. And I’ll try to get back to blogging more once I get back to the States in early May.

Standard
Flex/Flash/Actionscript

Docking ToolBar from Adobe Flex Team added to FlexLib

The Docking ToolBar component that was released by the Adobe Flex Team has been contributed to FlexLib. This component was originally released on Adobe Exchange. The description from the Flex team:

The docking toolbar component collectively helps managing toolbars in an application.

The toolbars can be docked to the top or bottom edges or kept floating within application area. The contents within a toolbar use a flow based layout approach.

A big thank you goes to Matt Chotin at Adobe for supporting the FlexLib project and getting this contribution into the library.

Future updates to the DockingToolBar will be found in the FlexLib project, and bugs and feature requests should be logged here.

Here’s a sample showing off the Docking ToolBar component:

This movie requires Flash Player 9.

Standard
Flex/Flash/Actionscript

List control for the one-armed man – take two

Here’s my second attempt at making a List control for Flex that has the functionality of using the Control and Shift keys, but without making the user actually press the Control or Shift keys. For those poor programmers who have been crippled by RSI, now you can at least drag around list data with your one good hand.

This version is much better than the previous version. Now you click on an item and drag to select multiple items. You can still drag and drop items from one list to another. The only difference is that you must first select the items, then click and drag to move items to the other list. Control-click functionality is the default if you only click one item. If you drag to select items and try to select below the visible items it will scroll the list into view.

Here’s the source.

This movie requires Flash Player 9.

Standard
Flex/Flash/Actionscript

List control for the one-armed man

This is a little experiment to play with a different method of selecting items in a Flex List control. It allows you to re-create some of the multiple selection options you usually get by holding down the control or shift keys while you select items. But now you don’t need to hold down the control or shift keys. Just play with it to see what I mean, it’s hard to explain.

There was a question on flexcoders that was about something like this. I’m not sure if this little experiment solved the right problem for the original poster, but trying to figure out how to get some of the functionality of using the control and shift keys without using the actual keys was kind of interesting (what can I say… item renderers and list controls turn me on). So this is what I came up with. Another thing to note is that the checkbox acts as a visual indicator only, it is not actually a clickable control.

View the source here.

This movie requires Flash Player 9.

Standard
Flex/Flash/Actionscript

Updated MXNA RSS Reader Flex App – Now With Source

Here’s the newest version of the MXNA RSS Reader Flex application that was shown at 360Flex. It’s been updated and another Flex community component was added into the mix. And full source is published. I call it ZOMGZ!!1 RSS Reader.

The updated recipe is:

So what’s new?
I added the sticky tooltip component by Maikel Sibbald, which shows the description of the article when you hover your mouse over it. I think it looks sweet. There’s a new icon for the most popular posts of the day. There’s also an options panel (click the rightmost icon). You can configure how many posts you want to read for each category. And you can choose to use the “Smart Categories” or the regular categories that MXNA offers (not all categories have smart categories that correspond). Those options are stored in a shared object, so next time you load the app it will remember your settings. And it will automatically load the last category you were browsing. I utilized a better method for sizing the font in the TreeMap that I didn’t realize Josh had included in the component. It looks a lot better now. I had to make a small modification to the component to get it work with embedded fonts, but now the fonts looks silky smooth and they show up in the reflection. I made some performance enhancements, turns out that drawing that reflection when you’re using embedded fonts really eats up processing power.

Future development
I’ve been working on getting the source to an acceptable point to release it to the wild. I didn’t get all this code to a point I’m truly happy with, a lot of it’s uncommented, but my ADD is kicking in and I’m tired of working on it, so here it is as it is. Use it to learn, use it for inspiration, use it for whatever. The only restriction is that Josh’s TreeMap is licensed under the GPL license (AFAIK the other stuff is MIT-ish license). I dropped this into an Apollo app and it kind of makes a cool desktop RSS app, but I didn’t add anything that really makes it any better than the web version, so I’m not going to release the Apollo version. I’m not planning on working on it anymore. I’ll be working on a few other RSS visualization apps.

ZOMGZ!!1

So check out the example below. View the source here.

[Or launch it in it’s own window: here’s the link]

This movie requires Flash Player 9.

Standard
Flex/Flash/Actionscript

Fire component added to FlexLib

I added a new Fire component to the FlexLib library. This is a Flex component that creates a fire or smoke effect. It can be customized in a variety of ways, including setting multiple colors for the flame. Check out the demo app below to see a few different presets I came up with. Try playing around with the different controls and you’ll get an idea of the different kinds of effects that are possible.

The key to this is using the perlinNoise function of the BitmapData class, and the DisplacementMapFilter. I don’t claim to be an expert on using these functions. Others have written about using them, I just copied the same approach.

View the documentation
View the example in a new window.

To get the source of the Fire component, download the FlexLib project from Google code.

And don’t complain about this using a lot of CPU horsepower, go get a faster machine 😛 Or look at the source and figure out how to optimize it for better performance and contribute the improvements back to FlexLib.

This movie requires Flash Player 9.

Oh, and for anyone wondering, I’ll be releasing the source for the RSS reader that was shown at 360Flex… soon. Probably tomorrow. And it’s an even more pimped out version.

Standard