ActionScript: Emerging Free Book on Bitmaps

Thibault Imbert, an Adobe Systems Engineer, is working on a new book, "What can you do with bytes?", that he'll be releasing as a downloadable pdf for free.

Thibault does a lot of interesting work with ActionScript and his site is worth frequenting (especially if you are francophone as he is also one of the few, maybe only one writing AS books in French). Anyway, he is releasing as he goes and, as of the time of this post, the first 45 pages are available.

Incidentally, I came across this while looking for a way to inject animated gifs into Flash. There is a nifty site, ajaxload, that has a free animated gif generation service for throbbers.

Flex: (Somewhat) Simple ColorMatrixFilter Example

As my Simple Actionscript Color Separator Class seemed to be popular, I thought that I would expand on the concept of color in Flash a bit by providing a demonstration of the ColorMatrixFilter. Mostly this is for my own gratification as I have been investigating bitmap manipulation with ActionScript 3.0 and color is a big part of that (There are also convolution and displacement filtering capabilities and I will eventually be posting simple examples of those).

So, the quick recap is that each pixel is made up of 4 channels: Red, Green, Blue and an Alpha channel that controls opacity. These channels are expressed as hexadecimal and aggregated together into a neat 32bit number (See the previous color post for more details). When the ColorMatrixFilter is applied, the Flash player will iterate over every pixel in a bitmap and apply the rules of the filter on an individual basis. This is particularly powerful, but, as one might expect with a ColorMatrixFilter, there is a matrix. In this case, it is a 4 x 5 matrix where each row represents a channel of the bitmap and the columns represent the channels as well as an offset. So the rows correspond to Red, Green, Blue and Alpha and the columns represent Red, Gree, Blue, Alpha and Offset.

For any given pixel, the final channel values are expressed as the sum of the products added to the offset. That probably didn't make as much sense as I might hope, so let's consider the following matrix, known as the identity matrix. This is a good place to begin as this has no impact on the final color:

[More]

Keyboard vs Mouse

Maybe it is because I am enamoured with the world's ugliest, but potentially coolest mouse, or maybe it's that my own mouse is developing quirks that cause me to believe that it is not long for this world, but I've been looking at acquiring a new primary HID. Along those travels, I came across a very old discussion comparing the Keyboards vs Mice. Apparently, Apple spent $50,000,000 in the late '80s, and that's when $50 million was worth something, to study the Apple Human Interface. The result was the discovery of two facts:

  • Test subjects consistently report that keyboarding is faster than mousing.
  • The stopwatch consistently proves mousing is faster than keyboarding.

Like many things tech, and especially since Apple is involved, opinions run strongly in many directions. My own concerns are my own requirements for interfacing with the hunk of plastic, silicon and dopants at my desk and what sort of experience do I offer users in the applications that I create, web or otherwise.

I gotta imagine that there are thresholds and conditions that would impact the truth of those two "facts". One person mentioned in the article says that "there are NO command key equivalents in my product, Smart Labels, except for Undo, Cut, Copy and Paste". The reasoning is that, even though the user may perceive there to be a value in using additional shortcuts, he won't allow it. That seems extreme. What happens when the desired action is hidden behind several layers of menuing or if the action is contextual and you are already using the mouse to highlight the text (modifying case through shortcuts would be very preferable to highlighting and hunting). My own inclination is to add keyboard shortcuts when time or interface will allow me. That doesn't always work and I have lost some recent battles at work to implement minimalistic interfaces that use only keyboard shortcuts.

In that case, it was a dialog box, created by a mouse event that just contained a single text input with listeners for ENTER and ESCAPE. My reasoning was that the act of calling the dialog would provide the context for the input, hence no label, and that ENTER and ESCAPE are natural behaviors. As I said, I lost and now the little interface that could have been was obliged to support a Label, a submit Button, a Cancel button (as the corner "X") and an instruction line. My opinion is that, styling aside, the interface is uglier and code is heavier. (Apparently, I might be a little bitter about this)

Anyway, where are the lines between performance and usability? I've been perusing user experience resources and the focus has been on eliminating the need for a user to think. And, for casual use software, that makes a lot of sense. However, for productivity software where a user will spend much of the day, I gotta imagine that the kind and thoughtful UI developer is going to allow for improvements in performance that occur through user training - though that means a lot more than just adding keyboard shortcuts.

Simple Actionscript Color Separator Class

I saw a blog post discussing how to grab the separate composite colors from a unit in ActionScript. This has probably been addressed and solved many times, but there does not seem to be a built-in object to take care of this bit of functionality. You'd think that mx.utils.ColorUtil would be a natural place to find such things, but not so much.

So while the author chose to go with string manipulation, I figure it would be a good opportunity to do a little binary work and create a simple little class to keep everything tidy.

The general scheme is to perform a Right Shift and then an And. The color information is either 24 or 32 bit with the extra 8 bits in the latter describing the opacity of the pixel. Shifting makes the desired color channel the least significant amount and the logical and with 0xFF will remove any other remaining information. So, to get the channels, it would work out like the following:

[More]

Actionscript Apps for Android

Since I have recently hopped onto the Android bandwagon, I've been perusing the market. After installing the working Tricorder everything does some weak by comparison, but I did press on.

Surprisingly, I found two ActionScript related apps for Android lately:

  • ActionScript Reference for Android
  • Flubble

ActionScript Reference for Android

This ought to be rather self-explanatory. Jonathan Dunlap has whipped together a little android app that offers the AS3 helpdocs. Nothing earth shattering, but a nice way to spelunk the docs. I'm thinking that it'll be my go-to app when I have to kill some time.

Flubble

I haven't quite figured out what to make of Flubble yet. Ostensibly, it is a stubbing app for ActionScript classes. I haven't used this for an actual project yet, but I have run some tests and received my class files both as AS3 and XML. The XML is an interesting option that threatens to have some potential, though I haven't worked out quite how I would use it. It looks to be a nifty little app and I hope that I can fit it into the workflow in some way.

Of course, there are a lot of generic supporting apps to be found (text editors, ftp clients, ftp server (odd), flash card makers and the like), but for some reason I was surprised to find an app like Flubble. It does get the wheels turning about what sort of apps could be created for the platform.

Flex - Rounded Corner Component with Tiled Bitmap Background

Lately, I have been getting more involved into working with the visual aspect of Flex. Up to now, I had been able to pass off the styling to Alex after working on the functionality or have just worked on projects where the visuals weren't a concern. Anyway, it is often good to get opportunities to explore.

So, the simple thing that I needed to do was to create a rectangular component based on mx:Canvas with a tiling background and rounded corners. Figuring this ought to be a straightforward thing to do, I blithely set about it.

First snag: Flex doesn't seem to offer a straightforward way of identifying a repeatable background for the Canvas class. Quick searching revealed that one can do this with Degrafa, but I didn't want to go that route. (Not that Degrafa isn't tremendous, it just seems like a lot of overhead just to tile a background image.) There is another solution for setting a tiled image as a background.

That is a really nice solution, but, for my immediate purposes, has distracting elements like loading the image at run-time. Run-time loading could be an incredibly useful feature, and it is worth noting, but if you have a small, single image you want to use, it is nicer to just embed it and not have dependencies at deployment. The core of the solution is to use lower level AS3 functions to draw a rectangled that is filled with the bitmap of choice.

So, a quick bit of code that shows the embedded image written as a tiled background for the component:

[More]

Flash & Flex Developer Magazine Is Free With Community Resources

For those that may not be aware, Flash & Flex Developer Magazine has moved to a free, online distribution model. This is a plus because they used to be quite expensive. I'm not the biggest fan of their site layout, it used to be torturous to navigate it, but they seem to be improving it.

And, as a bonus, they have a flash and flex community section that allows you to add your own blog, along with whatever description you care to give yourself (here is the ShortFusion blog profile). They also have areas to promote usergroups and events.

[More]

Question about Flash Cross-Compile to iPhone

I mentioned in my last post that an iPhone developer attended a Flex presentation that I gave. He was hoping to get some info on how he might use Flash as a means of producing apps instead of Objective C. Not sure what development environments exist for iPhone development presently, but the idea of using Flash is obviously titillating to some.

[More]

Online Actionscript IDE

I often muse that one of the primary reasons I can't break the MS Windows habit is that Adobe doesn't treat Linux as a first class target platform. I've blogged about this before, but it is still annoying.

And Mac isn't an option for several reasons:

[More]

BlogCFC was created by Raymond Camden. This blog is running version 5.9.1.001. Contact Blog Owner