Skip to content

wonderwhy-er blog

Web, RIA, GAMES

Archive

Category: My Stuff

Over last months of 2010 I was coming to realization that I want to be able not only to make multimedia Flash apps in web but also build HTML pages and services around them. So decided to start slowly learning some. Also with HTML5 making core web stack more and more potent it would make me more prepared for challenges where HTML5 will be a better choice then Flash for rich internet applications.

Not that I don’t know or did not know some. I have basic knowledge of HTML/CSS/JS/PHP/MySQL. Kind of standard stack used today for various cases. But here my knowledge is gather from various small cases and web examples. Probably only part of it where I did get some formal education is relational data bases. What I wanted was to broaden my knowledge in all this.

Asking friends for ideas about good books to start from I was often asked “why books?”. Today you can learn anything from the web, thousands of examples, tutorials and documentation sites and active developer communities allow anyone to learn to program anything.

Thing is that I find it to be a bad way to start. Tutorials and examples often concentrate on solving something specific, are not always made with big picture in mind or sometimes even made badly and teach you bad things. I prefer to start from some book that give a broad and not deep view, showing how it is meant to be done without going too deep in to the details(details I will dig out later if I will need). I need this to get some ground under my feet from where I can start. And then explore the web myself knowing for what to look, what’s good and what’s not so good etc etc.

For starters I picked a little bit unusual direction :) As I mentioned I more or less know PHP and I wanted to try something new. Also for some time I was curious about Google App Engine. Pocking around GAE I found that probably best languages for that platform right now are Python and Java. Well I knew Java years back and don’t want to return. So I went in direction of Python.

In last December I was ordering some books from Amazon and ended up ordering 3 books on web technologies.

Google App Engine

First book from those I started to read was specifically about Google App Engine. This book covers whole GAE platform as far as I can tell. On programming part it includes both Python and Java specifics, classes and code examples. It helps you trough your first Google App Engine application. Big part of it is Data Store. Then it comes trough various other features of GAE like memory cache, google account integration apis, various other built in apis.

For me most interesting part was Data Store. I am pretty familiar with relational databases and ideas behind them and was always curious what Data Store is, how it works, where better to use it and this books gives pretty good overview on that side. Actually something like 1/3 of this book is about Data Store related stuff.

Some interesting things about App Engine. It was designed with “return answer as fast as possible”  ideology for rich web apps. One related to that interesting feature is that app can return result first and then start working on updating data, indexes etc. I guess that possible to do with any stack but I never looked on it from that optimization point.

As far as Data Store goes it reminds me of simple Object Orientated Database. It basically stores entities by unique keys that may have properties and something like classes forced by code. Also Data Store allows building indexes to run queries on some of the property types. As far as I can say there are 3 significant differences from SQL database:

  • Query language is simple, does not allow joins and some types of queries that need calculations
  • You can retrieve entities not trough queries but directly if you know their unique keys, it is lot faster then trough query
  • It is possible to store an array as entity property, it also allows running queries that target content of arrays so you can get entities who have some kind of values in their array typed property, you can store keys in such array making kind of Object Orientated version of one to many relationship between entities

Another thing is that keys are constructed in a way where first part of key is application ID, and you don’t even see it, which means that each app can only get access  to entities it has created. Can’t access other apps data directly. Also there are limitations on how many entities you can access at once which along with other GQL limitations makes GAE a bad platform for solutions that for example need t work with large amount of data providing statistical info on it.

I guess that would be it on that book. Overall it gives good overview for GAE providing a good start point if you want to know what GAE can and can not do.

CSS Mastery

Another topic I was curious about but never was really getting to know it better was CSS.

Basically its something I knew what it was for but did not knew general ideas behind it and how it is really meant to be used. This book claims to be a book for those who have been using CSS for some time but don’t feel they are experts yet. Or people with basic knowledge of CSS. After reading this book I must say that its rather a book for starters. It rather teaches clean and simple CSS/HTML showing where common pitfalls are and all.

This books covers essential parts of CSS, selectors, techniques of layout, advanced CSS3 features and how to do something like that in CSS2.1 using old methods and tricks.

I think best part of this books is that it teaches how it should be done and why. Why HTML part of pages should be designed as meaning and structure while all styling should go in to CSS. Author adds small examples from his experience which make it pretty clear why it should be like that.  Or another thing is how using hacking to fix problems is a bad idea as problems are fixed as browsers are updated. So your hacky fix now becomes a bug.

Some 7 years ago coming from Java/C/Pascal background I started to dig in to HTML/CSS/JS and Flash. Flash slowly win me over. It was a way to develop Apps while HTML seemed like way to developer styled text pages along with a bonus of serious cross browser inconsistencies/bugs and limitations. Over these 7 years things seemed to improve especially on JS/CSS front.

Sadly coming from Flash I still find that even CSS3 is insufficient to style things cleanly. Firstly today style is not only about static visuals. Its about animations, reaction to user actions, its about visual behavior of interfaces. Now CSS3 includes animations but that’s not enough. I think big problem is  that you can’t reference values in CSS. For example one of examples in the book shows how to make 3 text columns to be of one dynamic height. Thing is that you can have them aether of static height or they all will scale according to size of text inside them. As you can’t reference values in CSS what author proposes is to make all columns of large height, then use container of those columns in “hakcy” way which resizes according its content actual size. Now container is of size of highest column. And now use overflow property to cut out unnecessary height of columns. Of course such trick is possible only with simple column style. Now then all I wanted is to make 3 columns to share same dynamic size. And I end up with doing lot of trickery to get a limited solution. This kind of lets me down…

Another example is vertical content centering on page. Solution looks pretty clear but is limited too. Just make your content top padding 50% which will move its top side to center of page. And then, with different technique, move content up by half of its height. Yay it is centered. Sounds even intuitive and logical in idea. But you can’t target values in CSS. So you can’t target its own height in position style. So you can’t center object vertically if it has dynamic size in HTML/CSS… Or at least it seems so.

Well anyways this all is CSS problems. This books does good work communicating good and correct way of dividing content and style of your HTML/CSS pages. I guess many HTML/CSS problems can be solved with JSS/jQuery filling in position of visual and other behavior for HTML/JS/CSS at least for now.

Python Web Development with Django

Another book I only just started to read is this one. I thought that it is a good idea to learn not PHP/Python language directly for web development(as that I can do myself). What I wanted to learn is how to develop good web solutions too. How to architect your engine, authentication, user content, HTML output components etc. I wanted to know best practices in how to develop your engine/framework for web site building. And what’s a better way then learning some framework and seeing how they done things there.

Another thing with Python books is that Python is a language used for broad number of things. While PHP is mostly used for web development Python started elsewhere as general purpose language like C. As a result majority of books don’t cover Python use as web development language almost at all. And thus majority of those books are of no interest for me in current situation. For that reason picking Python based web development framework book seemed like a good idea too.

Now first chapters of this book gives incremental introduction to Python first which is perfect :) I knew for a while that Python used spaces and new lines as part of its syntax instead of various braces. I always was finding that it is both good and bad. Good that everyone writes in same style as it is enforced trough syntax, also makes language less bloated with special symbols and more readable. Sadly in some cases it also makes language less readable as you can’t arbitrary style some part of code for better readability.

I just only started this book but so far I must say I really like some features of Python. They make language a lot smaller when performing task with array for example. Here are few interesting examples:

  • string[1] – like in any other language it returns strings second character
  • string[-1] – here good things start, it returns strings last character, so if index in [] is less then 0 array length is added
  • string[:1] – now what? Turns out that Python extended this operator to allow ranges. In this case it will return first two characters of this string.
  • string[1:3] – now this is full syntax returning second, third and fourth symbols in the string.
  • string[1:] – and this will return whole string without first character :)

Anyways I have still much to read from this one so no more comments on it so far.

Other books and some practice

Basically this is it from this book order but there are two more I would like to buy. One on JavaScript/jQuery and one on some PHP framework to improve my knowledge in those directions. Also I have few test projects planed to try and use these technologies. After reading book on CSS I already updated homepage a little(here how it looked before), planing to do more work later on it. Also planing to try and do two projects for practice on GAE later.

After playing with spectrum next thing I wanted to play with was sound signal itself. Checking stuff initially I noticed that sound signal looks the closest to my association with what I hear. Actually old console games music looks geometrical for example :) Noticed that back in the day listening to some Amiga music emulator made in Flash probably by Andre Michell. Sadly don’t remember where it was now.

Experiments

You can select different visualizers in bottom left side combobox.

  • Direction – was a first I tried. Just using sound signal as angular speed for a moving particle. Nothing special but looks pretty cool :)
  • Direction 2 – with direction 1 particle moved around the screen and teleported to opposite side when it was going outside of screen. Good but sometimes it would rotate somewhere in a corner where you could not see much. With direction 2 I tried to make camera follow the particle. Not perfect and camera is too shaky with some music :)
  • Burst - new year was coming and both directions had a problem with music that had lot of frequencies in them like rock. They would just spin in place chaotically. Wanted them to kind of explode at such times so made burst as a kind of fireworks  thing :)
  • BurstStereo - realized after making first burst that I was using only one of two channels for music. Decided to make a particle for other channel. Looks like just two particles  that are not really connected :)
  • Beat - seen one place that sum of amplitude of signal is kind of a beat, I would rather say that its a volume :)
  • Radial – here I just wanted to see how it would look if instead of moving particle I just change direction I shoot them. Turned out to be boring :)
  • Opposition – another try with two channels. Now two bursts are attached to same particle, looks weird to be honest :)

MP3 Parsing

Before I was using, mp3filereferance by FlexibleFactory to load music from ByteArray. Sadly it had a flaw of throwing “End of file” for some songs. I suspect that its about damaged files. So I decided to try as3swf lib that can do the same. Sadly it has flaws too. Firstly lib is big and slows down compilation a lot(which is a pain). Secondly it does not load all music too. From mine I noticed that it throws this error “Unsupported sampling rate: 48000 Hz”. Good part is that wonderfl includes as3swf which means I will be able to port some of my music experiments to wonderfl easily somewhere in February.

ComputeSpectrum problems

Also I stumbled on Flash bug I wrote about here. Basically when you have two flash open in your browser where one uses computeSpectrum and other plays song on other domain you will have a security sandbox violation error. Thing is that you can’t access stream data that is streamed from other domain and computeSpectrum seems to be global for Flash player instance. But I think I tackled it well in musical fireworks.

More things to try

  • I am thinking on trying to fall back to mp3filereferance when as2swf fails to improve things a little.
  • Also I am thinking on trying microphone input instead of mp3 too. Flash 10.1+ should be able to do it.
  • And finally its time to start making final entry for the contest using all things I learned so far :)

That’s it :)

So 2010 is almost over and 2011 is almost here. Another year have gone by. First thing first:

Happy New Year everyone :) Here as part of my audio visualization journey made Musical Fireworks, enjoy(click picture to see it):

Year summary

And now to summarize on how things went this year for me. Wanted to collect in one place where I was at the beginning and where I am now and for now not precisely but say where I want to go next year.

Work

Little bit longer then a year I am working at innoWate nad am programming Flash games for social networks like Facebook and Vkontakte.

It was rich in experience year:

  • I participated in making two social games directly and helping indirectly in making few others
  • Learned pretty much about social network APIs that are mostly inspired by Facebook
  • Learned about many Flash bugs, inconsistencies, performance issues and some workarounds for them

That are good parts :)   Now some stats

On 12 Aprila of 2010 I installed Procastitracker at work, this software allows me to see how much time I spend in what applications so what we have there:

  • 170 working days since April, two weeks of vacation in August, seems about right
  • 1414 working hours over those 170 days

That makes something like 8 hours 20 minutes of average working time per day or 54 hours of overtime…

In what applications it was spent:

  • 535 hours spent in Firefox
  • 356 hours spent in Flash Builder 4
  • 176 hours spent in SkyPe
  • 82 hours spent in Flash Player
  • 54 hours spent in Windows Explorer (files/folders stuff)
  • 36 hours spent in Flash CS5
  • 27 hours spent in Chrome, lately FF become very bad for Flash development, hangs, crashes, lags, few times tried to switch but FF extensions equivalents in Chrome  are not on par yet
  • 25 hours spent in FTP manager
  • 7 hours in Procastritracker itself :)

You can see I missed some things here and there + there are things where Procastitracker does not know what I was using. Still I covered 90% of things I guess. So yeah 500+ hours or more then 1/3 of my time is spent in browser, Procastitracker is smart enough to see on which sites too:

  • 74 hour on Facebook, testing our stuff, checking competitors stuff, communicating with friends etc
  • 62 hour in Vkontakte one of biggest Russian social networks(there are few), mostly testing our games and working with their API
  • 49 hour on Google sites, gmail, reader, statistics tools and google  search itself, soon I guess chrome store will become a portion of it too
  • 38 hour on DeviantArt, well that’s mostly entertainment stuff, checking works, communicating etc
  • 25 hour on private work related sites, various tools, statistics and game deployment tools
  • 20 hour on One(local social network), entertainment too, local network, photos, friends, communication too
  • 18 hour on Mail.ru, rather new social network from most popular Russian email provider, big player in social arena now too, also testing games and stuff
  • 12 hour Odnoklassniki.ru, probably biggest and oldest Russian social network, also worst API in industry, site too, unstable, user unfriendly, really hard to test and use as platform, but also with most active players community it seems
  • 10 hour YouTube, hehe :)
  • 7 hour in my blog here :)
  • 4 hour Wikipedia, hmm seems small

It is roughly 60% of spent time in FF, there are a lot of small sites and Procastitracker does not allow to group the efficiently so I have no idea on what kind of stuff rest of time was spent.

Activity on DeviantArt

  • Submitted 15 works which 40% less then year back
  • Also comments and views fell something like 50%

I really like DeviantArt and its community, sadly DA is stagnating, especially on Flash front. I wonder if at some point they will provide APIs so that people could start creating art related tools around DA platform. In meantime Flash programmers community is weak there, we lack gallery supervisor and position is open, what that means is that there is no one to be a buffer between DA staff and Flash creators community, Flash deviations do not get to Daily Deviation page (front page, best works of the day, nominated by gallery supervisors)  and also community is disorganized. Sad…

This blog

In first half of this year I registered a hosting and domain name, on 17 April I finished with blog preparations and made my first blogpost here. For long wanted personal, customizable blog that is not dependent/hosted on any social or blogging  platform.

  • Since then I made 54 post
  • There are 33 comments(some are mine in response to other comments)
  • I got something like ~5000  unique visits, 27k of visits overall (AwStats)
  • Those visits eat ~1.3Gb of traffic making it something like 37Kb per visit :)
  • Also I made PingMap and collected ~2k of unique ip pings to my blog so far
  • Also Akismet blocked 239 spam comments :)

Conclusions

Speaking of work, can’t say I am satisfied on many levels… Its a long talk and I will save it for different time but in short, each celebration in the world is a rush to make new features by that deadline. Planing is chaotic and I am not sure we have people who know what they are doing on game design side. I my self don’t really get appeal of game that companies like Zynga make. Anyways part of this is chaotic feature adding. And result of it all is hard to manage large projects on inside (feels bad for me as a programmer, I want to do my work well but I just can’t in such circumstances, partially I guess I lack experience but still)  and also games I am not proud of  from the outside…

On DeviantArt I guess I need to be more active but lack time. DA is good place for various things and getting audience for some things. Sad for me that I am degrading a little in my activity on DA.

On this blog side, I am more or less satisfied. I did not wrote as much as I would have liked, I have like 10-20 unfinished drafts for posts. Also my post quality is not very good. Bad English sometimes and not very deep posts aether. I want this blog to be more clean and useful to people with similar to mine interests but I don’t have time for that aether.

Next year

As you see from above I must say I am not completely satisfied with last year. I want to do a better job and be proud of things I do for a living. I want  to do more blogging and works for DA and with better quality. I am satisfied with what I was doing but now with how. So for next year I wish and want to do better and I do have some things planed to try and do better.

That’s it. Happy New Year!

The problem

Today while refactoring some global static classes code to be more manageable at work thought of one thing. Thing is that those classes stuff often should get initialized. Where initialization it is usually called? Well who knows, anywhere where it fits… With big project where you have many global managers like money manager, hints manager, events manager etc etc their initializers are usually hidden somewhere while they are used in multiple places. Now often it happens that something changes and needs to access that class sooner then it was needed before. What follow is probably null reference error or something similar. And now you need to go, figure out where it is initialized now, what needs to be done to initialize it sooner. Or just try to move code that needs it to some later stage… Sounds bad right? Some spaghetti code stuff in project where multiple programmers work on same code base. Especially when stuff in those global classes needs to be called in various places that can come at random order depending on server and user input.

Static initializers in AS3

So refactoring stuff I was thinking about this problem again. Interesting thing about Flash is that it uses lazy static class initialization. In short that means that static class is not initialized until it is referenced somewhere in code. Neat feature though still a compromise. We get start up performance as not all classes are initialized from the start but then we loose some as each time class is referenced there is a check for it being initialized(I guess, that’s how it usually is done). Now that’s good but what if we need not only to initialize variable but run some code. For example some parsing of variables content. Google for the rescue: Static initializers. Nice, short and clear article.

 

{

//put code that will be called when class if referenced for first time

}

 

There is one thing though. You can debug code inside those brackets. So I instead just put a call for some static function which I can debug then.

So now I have something like that:

 

public class GlobalMoneyManager

{

public static var PricesXML:XML;//set when loaded

{

Init();//initialization code called

}

public static function Init():void

{

//parsing prices, calling stuff, etc

}

}

 

 

 

Now then it works for me like that.

  1. Site/Game loads and XML with info is loaded.
  2. Then there are like 10 UIs that use information that needs to be retrieved from that XML but none of  them is shown at the start
  3. When user action results in one of those UIs showing up, UI is initialize and reference something in GlobalMoneyManager
  4. GlobalMoneyManager is initialized
  5. Static initializer code is called
  6. Init is called and class if filled with parsed info
  7. Control is returned to UI and data is accessed

The end

Works like magic. I wonder if there is a catch to this that would make it a bad coding style that raises more problems then it solves. So far I do not see any.

After doing initial template my next aim was to figure out what kind of info I could get out of sound signal + spectrum and how I could exploit it to effect colors, movement and shape of visualization.

First thing I decided to do was to go and see what kind of things people already made to figure out what kind of stuff could be extracted.

Cool audio visualizers

First place for me to stop was to go trough flight404 gallery at vimeo. I remember I was mesmerized many tiems by his works some of which are happen to be audio visualizers and here are two I picked out of his gallery:

Just click the picture to go and see videos on Vimeo. Check other his videos t00.

Then here are few random finds:

Now this one includes 3 visualizations:

I think I like third the most. Seems simple and yet kind of dancing along with music. Also I guess it would be possible to make such one in Flash but that’s not what I aim for. Even though ways it works behind the scene are interesting for any visualization.

And tastiest for the dessert. I seen it before but completely forgotten about. But it falls very close to what I want to achieve:

Now on representation part there are many elements I do not like. Mainly colors and that many effects are “pre-rendered” for exactly that song. But in core mechanics it exactly what I seek to make. Something even more abstract where user is responsible for part of visualization and also more colorful and closer to what Flight404 does. Big aims, not sure I will deliver but its fun journey anyways.

First experiments

In parallel with checking stuff from above I started to play with spectrum, listening various songs and trying to understand what kind of stuff I could get out of spectrum. Pretty quickly understood that I will not be able to extract information about “pitch” of music. Even though pitch is related sound frequency and sound signal spectrum is all about showing present frequencies you can’t really easily get various “pitches” out of it. I am not sure but it seems that pitch we hear is related to harmonics or signal fundamental frequencies. As far as I understand it works like that, we have harmonic of 2, then in spectrum we see frequency 2, 4, 6 and any other integer multiple of 2 present.  Now complex music contains many such base frequencies for instruments and human voice that all overlap and you can’t easily retrieve them. Anyways reading about it and thinking a little I decided to forget it, too hard and new for me to do it in few weeks. Also decided to search Amazon for books about math/physics and humans brain things behind magic of music and found those two books. I guess I will order one of them to read for self education. Should be interesting read.

After giving up on harmonics simple idea came to my mind pretty quickly on how alternatively draw spectrum. Results pleasantly surprised me (just love when my own ideas surprise me :D ). Here is small collection of experiments based on that idea along with various effects from my previous works(it may be processor intensive, did not invest much in optimization yet as it is work in progress):

It is interesting that out of all of them I like first the most. It is most simple but at the same time in in no way distracts from music in any way and seems to move best along with it while other visualization add their own movement that has nothing to with music…

Well that’s all for today’s post.

One group at DeviantArt.com called ActionScript-As-Art organized a new year audio visualization contest and I am planing to participate. So you can expect some posts about this during next weeks.

First thoughts

After reading about it I become really enthusiastic about this. I did number of music visualization things before but they all were in some way music signal spectrum based and you could easily see it. This time I wanted to dive deeper in to all that instead of just showing spectrum in some fancy way.

First things that came to my mind was this presentation at TED where presenter mentions interesting things about sounds. That we actually have some common associations of sounds with shapes and brightness. I bet we have even more common associations than what he mentioned. Anyways what I immediately wanted to try was digging up and trying to use all info on Sound Synesthesia I could. Here actually are some more of interesting links of his works: Re:Mark and Messa di Voice and you can see one more by clicking above image.

Cool stuff, not sure how close I could get to that kind of things but will see :)

Template

First things I wanted to do was to make an open source template that would feature loading mp3 from FileReference and rewinding as those are two features I would like to see in all contest participants works. Hope at leas some will add those features themselves or checking this template I made. Here is the template:

And you can download source here.

That’s all for now. But more coming soon :)

Introduction

(Warning, this post is LARGE)

With raise of large audiences in social games and trend of micro transactions and “in game purchase” a lot of big and small companies started to makes Flash games. This results in heated competition to deliver next game that stands out in various ways. In AAA games (sadly to be honest) one of the edges to stand out was and is graphics. Probably because of spend effort and gained attention ratio and that after seeing good graphics old starts to itch the eye. Now with this competition for hundredths of millions of players market same starts to happen in a browser with Flash being the most popular technology at use at the moment. This leads to Flash rendering being pushed to the limit and wondering in to uncharted combination of rendering techniques and various pitfalls they bring.

Recently some discussion rose around using Flash display list vs using custom based rendering based on BitmapData. One of such conversations was risen by SocialCity developer discussing what kind of compromises they did making SocialCity. And such compromise is pretty common among various desktop developers coming to Flash as that’s very similar to what they were doing there I  guess. Anyways that article got attention of a Flash developer who was making games using Flash for a while before that market heat up that much. So he made number of his own tests and comparisons on how good Flash display list is vs BitmapData blitting.

continue reading…

Blog PingMap

So month have passed since I made a PingMap for my blog.

I was not satisfied with it and wanted it to:

  1. Look better
  2. Be more informative

So in my spare time was doing various changes to it and now you can see result here. Changes I made:

  1. Wanted it not to look as separate dots but as some territories or something, initially tried Delaunay Triangulation but after playing a little just drawing dots and applying metaball effect worked better.
  2. Changed design to become more minimalistic and more to my taste
  3. Update GeoLite and published this month data, interesting that I hit got 500(making 1.5k together) new unique pings in one month where previously I gathered 1k in some 5 months or something :)

Also moved the old one here with old data for anyone who would like to see first version:

I am still not satisfied with it and here are some things I want to change/add:

  1. Change how it is colored, so far failed with it. I want it to be colored in a way where you could see right away where things are bigger and where smaller, right now it is not like that. Having trouble because of uneven distribution of things. Simple linear gradient would not work no meter what you do. So I want to improve that part.
  2. Also I want to add tabs, move About to a tab, add stats tab with histograms and other descriptive info on a data set.
  3. Started to think that it would have been cool to see a time lapse so that I could load and show data by month or even anime how it changes from month to month. Don’t know how to do it efficiently yet.

Well that’s it for now :)

HSL - click to see Flash example

Recently forking this wonderfl flash and playing and making this one out of it I needed easy way to have kind of a rainbow of bright colors. Easiest way I know to have one is just to use Hue/Saturation/Lightness color model(or just HSL) as from 0 to 360 hue values it goes trough RGB and CMY colors gradient. And I went of looking for some simple example to use. I found 3.

  • Here is first one by Quasimondo I saw before. Sadly for some reason it did not work well for me. He also mentions that it is not 100% correct.
  • Then this at Snipplr but it needs additional classes, seems large and its conversion function is just too weird.
  • And then I remembered that wonderfl has frocessing libs included. And I correctly suspected that it should have HSL class. I ended up using it in that my colored nebula cock thing.

But… In the end when looking for this I wanted something small and simple. Not bunch of color classes I would need to drag with me to small experiments. So I decided quickly make one function that gets alpha, hue, saturation and  lightness as an input and returns a 32 bit ARGB color value. Simple as that. I went with used a pseudo code from wiki article as base and made this

function HSLtoRGB(a:Number=1,hue:Number=0,saturation:Number=0.5,lightness:Number=1):uint{
a = Math.max(0,Math.min(1,a));
saturation = Math.max(0,Math.min(1,saturation));
lightness = Math.max(0,Math.min(1,lightness));
hue = hue%360;
if(hue<0)hue+=360;
hue/=60;
var C:Number = (1-Math.abs(2*lightness-1))*saturation;
var X:Number = C*(1-Math.abs((hue%2)-1));
var m:Number = lightness-0.5*C;
C=(C+m)*255;
X=(X+m)*255;
m*=255;
if(hue<1) return (Math.round(a*255)<<24)+(C<<16)+(X<<8)+m;
if(hue<2) return (Math.round(a*255)<<24)+(X<<16)+(C<<8)+m;
if(hue<3) return (Math.round(a*255)<<24)+(m<<16)+(C<<8)+X;
if(hue<4) return (Math.round(a*255)<<24)+(m<<16)+(X<<8)+C;
if(hue<5) return (Math.round(a*255)<<24)+(X<<16)+(m<<8)+C;
return (Math.round(a*255)<<24)+(C<<16)+(m<<8)+X;
}

Its not well optimized but is as simple as it gets. Could serve as base for some color related classes and modified where needed. You can see result of its usage at top picture and click it to follow to a usage example that shows RGB and HSL values under the mouse. It features a 2D gradient going from left to right from -360 to 720 hue values and from 0 to 1 of lightness values from top to bottom. Feel free to use and modify ;)

Just quick share of something small but probably useful.

I kind of find native AS3 trace() not that useful when your app is running in a browser or even on someones else machine. Yes you can configure it to output traces to a file somewhere but that is not that useful aether. So usually I preferred to make my own trace function and show it some TextField. Well that far from perfect too.

Recently I made this simple logger class. Idea was just to track log and allow copying it to clipboard. And then you can paste it to text editor of your choice and search/filter/format it to your hearts content.

Here how to use it

import Logger;

//use like this
Logger.log("Hellow world!");

//To use not to use native trace()

Logger.useTrace = false;

//sets textfield for visual output
Logger.setTextOutput(out);

//Copies log content to clipboard

Logger.copy()

//adds context menu item clicking on which calls Logger.copy()
Logger.addMenuItem(this);

 

 

And here a small example to show how it looks.