Tuesday, February 26, 2008
Button Conventions
No, this isn't about a couple thousand buttons showing their wares, this is about what people expect in a button. I decided to write this because all to often I find myself saying something like 'buttons should work on release, not on press'. They should. You should have the option of pressing on the button, and then pulling the cursor away and releasing, because you decided mid-click that was the wrong button. This is how most all apps, and even hyperlinks, behave. And that won't work if developers are using on press code to initiate button actions. So stop making me say it, and just do it right - buttons should invoke their actions on release, not on press. (Unless you have a really good reason)
Friday, February 15, 2008
May The First
It wasn't until May 1st last year that I hit 300 miles on the bike. This year I'm already over 300. Hopefully it'll pay off a little, since I'll be racing Comp. Though I do wonder if I'll see another medal before 2012.
Wednesday, February 13, 2008
Using Code Names
I was just getting in a ride on the trainer and heard a great tip on a show I was watching. If your business is anything like ours, you likely do some of your work under an NDA - Non Disclosure Agreement. Essentially, this means you can't tell anyone for whom your working.
To make it so you can still talk about "the company" assign them a code name. Use the code name in all correspondence and in all conversations. This way everyone in your company can talk about "the company", and they all know to whom you're referring - but outsiders are none the wiser.
Given that I recently made such a faux pas, I'm definitely going to start using this practice. My first code name... "General Lee".
To make it so you can still talk about "the company" assign them a code name. Use the code name in all correspondence and in all conversations. This way everyone in your company can talk about "the company", and they all know to whom you're referring - but outsiders are none the wiser.
Given that I recently made such a faux pas, I'm definitely going to start using this practice. My first code name... "General Lee".
Problem with SWFObject?
I've seen a lot of posts over the past week or so regarding issues people are having with SWFObject and IE - after upgrading to player 9.0.115.0. From my understanding this is nothing to do with the player, and all to do with your IE having a corrupt player install. The solution is to use the official uninstaller, and then re-install the new player. (Or use a friggin decent browser - such as Firefox)
Adobe has some information on this issue here: http://www.adobe.com/go/tn_14157
Adobe has some information on this issue here: http://www.adobe.com/go/tn_14157
Saturday, February 9, 2008
Unity - Windows
I used to be a Director guy. Because, for a time Director was king of multimedia - and to some extent still is. A lot of us got really excited when Director 8.5 was released and included a real-time 3D engine courtesy of Intel. Macromedia had the online 3D world by the balls. But... they dropped those balls and Director's 3D engine has sat in it's current state all this time. Seven damn years. The whole time the online Director community clamored for updates. And the whole time Macromedia ignored them. And Adobe continues the tradition.
Enter Unity. Unity is actually worked on. Imagine that. So much so that one time product manager, all around good-guy, and 3D nut, Tom Higgins left Macromedia when it was bought by Adobe and went to Unity. That speaks volumes. Unity has everything Director's now antiquated engine doesn't. It has shadows, glows, speed, DX9 support and more. It's faster, leaner and just plain better in every way.
The problem with Unity however, was that it's editor was Mac only. But not for much longer. Unity is currently working on a Windows port of their editor. Wa-freaking-hoo. So, if you're interested in making online 3D content do yourself a favor and have a look at Unity.
Check it out.
Enter Unity. Unity is actually worked on. Imagine that. So much so that one time product manager, all around good-guy, and 3D nut, Tom Higgins left Macromedia when it was bought by Adobe and went to Unity. That speaks volumes. Unity has everything Director's now antiquated engine doesn't. It has shadows, glows, speed, DX9 support and more. It's faster, leaner and just plain better in every way.
The problem with Unity however, was that it's editor was Mac only. But not for much longer. Unity is currently working on a Windows port of their editor. Wa-freaking-hoo. So, if you're interested in making online 3D content do yourself a favor and have a look at Unity.
Check it out.
Monday, February 4, 2008
Simple Array Compressor
I've been working on letting users save a jpeg from Flash to their own machine, which for the most part is no biggy even in AS2. The problem area for AS2 is the amount of data that must be sent to the server - typically an array of color values, one for every pixel in the image. So, even a small 200x200 image will generate an array with 40,000 entries - each being a 6 byte hex value. And, when you turn that into a string for posting to the server you get a 1 byte comma added between each entry. So, a 200x200 image turns into approximately a 280K upload - that will likely end up being a 30K jpeg.
So, the trick is to try and minimize the amount of data you send, which can be done in various ways including things like base64 encoding, or using LZW compression. I did try those methods, and while they do work, they were taking far too long (at least in VM1) to do their thing. Uploading the big-ass string was faster than compressing and uploading the small version. I was resigned to just sending the big string, but kept thinking there must be a way to somewhat minimize the impact. That's when I hit on this simple array compression technique that is reminiscent of RLE.
Here's the function:
function compressArray(orig:Array):Array{
var l = orig.length;
var comp:Array = new Array(); //new compressed array
for(var i = 0; i < l; i++){
comp[i] = "";
}
comp[0] = orig[0];
var lastEqualIndex = 0;
for(var i = 1; i < l; i++){
if(orig[i] != comp[lastEqualIndex]){
//new color
comp[i] = orig[i];
lastEqualIndex = i;
}
}
return comp;
}
It works like so - a new array, comp, is created, the same length as the original, and filled with "" - empty strings.
The first item in the new array is set to the first item in the original, and the initial 0 index is stored in lastEqualIndex - since the two arrays are now identical at index 0.
The original array is then iterated starting at the second item in the array - index 1, and going to the end. If the current item in the original array is different from the item in the comp array at the lastEqualIndex, then a new value has been encountered. It is stored in the new, comp, array and the lastEqualIndex is updated to reflect the current index in the loop.
What this accomplishes is creating a new array where runs of duplicate data are eliminated and only the initial value in the run is kept. The other items in the run are kept at their initial empty string values.
Example:
original: [FFFFFF, FFFFFF, AAAAAA, BBBBBB, AAAAAA, AAAAAA, AAAAAA, AAAAAA]
new version: [FFFFFF, , AAAAAA, BBBBBB, AAAAAA, , , ]
original: 55 bytes
new version: 31 bytes
A full 44% reduction
Here's some actual examples when the array is filled with color values:

As you can see, some images are more compressible than others, as is normal. I couldn't believe the last image saw an 86% reduction, I expected much worse from it.
The nice thing about this method, aside from the fact that it's extremely fast, is that the array indexes are preserved and so it's very easy to reconstruct the original array: If a value in the array is "", just use the last item (color) that wasn't empty. Simple as that.
So, the trick is to try and minimize the amount of data you send, which can be done in various ways including things like base64 encoding, or using LZW compression. I did try those methods, and while they do work, they were taking far too long (at least in VM1) to do their thing. Uploading the big-ass string was faster than compressing and uploading the small version. I was resigned to just sending the big string, but kept thinking there must be a way to somewhat minimize the impact. That's when I hit on this simple array compression technique that is reminiscent of RLE.
Here's the function:
function compressArray(orig:Array):Array{
var l = orig.length;
var comp:Array = new Array(); //new compressed array
for(var i = 0; i < l; i++){
comp[i] = "";
}
comp[0] = orig[0];
var lastEqualIndex = 0;
for(var i = 1; i < l; i++){
if(orig[i] != comp[lastEqualIndex]){
//new color
comp[i] = orig[i];
lastEqualIndex = i;
}
}
return comp;
}
It works like so - a new array, comp, is created, the same length as the original, and filled with "" - empty strings.
The first item in the new array is set to the first item in the original, and the initial 0 index is stored in lastEqualIndex - since the two arrays are now identical at index 0.
The original array is then iterated starting at the second item in the array - index 1, and going to the end. If the current item in the original array is different from the item in the comp array at the lastEqualIndex, then a new value has been encountered. It is stored in the new, comp, array and the lastEqualIndex is updated to reflect the current index in the loop.
What this accomplishes is creating a new array where runs of duplicate data are eliminated and only the initial value in the run is kept. The other items in the run are kept at their initial empty string values.
Example:
original: [FFFFFF, FFFFFF, AAAAAA, BBBBBB, AAAAAA, AAAAAA, AAAAAA, AAAAAA]
new version: [FFFFFF, , AAAAAA, BBBBBB, AAAAAA, , , ]
original: 55 bytes
new version: 31 bytes
A full 44% reduction
Here's some actual examples when the array is filled with color values:

As you can see, some images are more compressible than others, as is normal. I couldn't believe the last image saw an 86% reduction, I expected much worse from it.
The nice thing about this method, aside from the fact that it's extremely fast, is that the array indexes are preserved and so it's very easy to reconstruct the original array: If a value in the array is "", just use the last item (color) that wasn't empty. Simple as that.
Subscribe to:
Posts (Atom)
