LeichtgewichtLeichtgewicht

2009/02/06 – 16:57

ActionScript Rainbow

What a week! I have been to the Adobe Max in Japan (about which I want to write later) followed by a trip to my home town which sums up to a total estimate of 30000km traveled this one and a half weeks. I just managed to complete the documentation and optimization for the AS3 variant for the rainbow. This reminds me of good old as2lib days when the documentation took about 60% of the time. I also found a small bug in the HSB conversion which I fixed in the JavaScript implementation and I added small performance tweaks.

The ActionScript 3 Version looks quite different from the JavaScript version. Same as the JavaScript version this one includes a HSB and RGB util, a adopted ColorFade and the RainbowColor but it doesn’t use a RGB object but responds with a uint: a performance tweak which allows it to work easier with ColorTransform and other methods in flash. The ColorFade applies to DisplayObjects which was necessary for a comfortable integration. I know that a restriction to DisplayObject might not be fun so I introduced new fields in ColorFade that allows to access the colors directly which should allow you more flexibility. I repacked both versions to another subpackage name color which opens more options for future code. Usually I introduce this kind of packages only if too many classes are within one level but since there might come more with the next blog entries I just introduced them now.

Here is a flash example(notice that its synced with the JavaScript), click on it to stop the update and set it to a predefined color.

(Either JavaScript is not active or you are using an old version of Adobe Flash Player. Please install the newest Flash Player.)

Download

The ActionScript3 source of this example and the library can be found here, right next to the updated JavaScript source: here. There is also a updated example for the JavaScript example available here.

btw.: I could have used public functions like rgbToUint instead of RGB.toUint (within a class context) but somehow I feel quite familiar like that, would you prefer functions?

Tags: , ,

Comments

  1. Dmitry Fedorov

    I think sync mechanism is a very interesting thing by itself.
    Can you make a separate post about it?

Leave a Reply

Twitter Users!
Enter your personal information in the form or sign in with your Twitter account by clicking the button below.

Site informations

Martin Heidegger – Web Developerskype:mastakanedaxing:martin.heideggertwitter:leichtgewicht