Friday, May 12, 2006

Watch Manager -- Beating The System

Required:MTASC Compliant Delegate Class
Watch Manager Class

Example Files
Note: You may have to change the class names and import data in order to make sure your classpath is correct.

I've been writing this class on and off for fun (it really is a fetish) in the past week or so. It's not ment to replace events or even be used in an every day situtation if at all. I mainly wrote it to see if it could be done and, guess what, it can. The core of this class is two static methods: subscribe and unsubscribe. Subscribe adds the watch to the watch registry inside the class. Unsubscribe removes the watch from the registry.

Subscribe has four parameters.

  • $obj: A string representation of the object that contains the property to watch. Is 100% independent of scope.

  • $prop: A string that contains the property name to watch within $obj.

  • $scope: The scope that contains $obj[$prop].

  • $callback: Callback function for the watch. If the callback is outside of $scope you must use Delegate.create to reassign scope.

Unsubscribe only has one.

  • $wObj:An object that's returned from the subscribe method.

The watch manager class eliminates all the previous limitations of I listed in this post.

If you peep in the example files you can see exactly how it's used. If there are any bugs I'd like to know.

Monday, May 08, 2006

Basic ColourData Class --Updated--

Note: Requires ColourSpace class.

You may also need to change the import line and the class name dependant on where you put it in your classpath.

I made this class so I'd have an easier time managing many 32bit and 16bit colour values at once. It works rather nicely so I decided to put it up here for anyone else in need it.

Obligatory sample syntax:

var myColour:ColourData = new ColourData( 127, 166, 223, 16 );

var myColourHSL:Object = myColour.convert("RGB", "HSL");
for(var i in myColourHSL){

trace(i+": "+myColourHSL[i]);

myBitmap.setPixel32( _xmouse, _ymouse, myColour.toHex());

For 16 bit colour values simply replace the alpha param with null:

//16 Bit Colour
var myColour:ColourData = new ColourData(null, 100, 233, 87);

Any comments on what to add/remove would be greatly appreciated.

Best Font For Programming

The Proggy fonts have to be simply the best font for programming.

I perfer the Proggy Clean with slashed zero and bold punctuation. Out of the many fonts I've tried in the past two years this one is the easiest on the eyes and the bold punctuation is a must.

What it looks like in action (click for full size):