JS/AS Date Object from MySQL DATE or DATETIME

The ECMAScript Date object accepts a string that it pretty generously tries to convert to a valid date. However, DATE and DATETIME returns from MySQL are formatted Y-M-D, which will cause new Date(str) or Date.parse(str) to barf. The quick fix is just to use a simple RegExp to move the year to the 3rd position. […]

RegExp – match JS/AS/PHP/CSS comments

The following pattern matches comments used in JavaScript, ActionScript, PHP, CSS, etc (/* comments */, and // comments), greedily.

AS/JS Translating Colors

just some snippets re: color values. number to hex string:

hex string to number:

RGBA to RGB:

individual colors from number:

number from individual colors:

AS3 (VM2) versus JavaScript – performance

Back in 2004, I was comparing loop performance in AS2 – for, while, and do while. That expanded to testing the same against JavaScript. The upshot (!) was that do-while and while were the fastest, and pretty close to each other, and much faster than for, in both JS and AS2. More surprising to me […]

20 Tips to Optimize your ActionScript

Update 09/29/12 This article was written several years ago for Experts Exchange, and has proven to be a little more controversial than I expected or intended, mostly due to the (admittedly vague) reference to what I call AS3’s “fake” lazy evaluation, which happened to be (rather randomly) listed as the first tip. I’m removing that […]

RegExp – validate US Zip

Simple regular expression to validate US zip codes.

RegExp – validate US phone

A regular expression to validate US phone numbers. Works in all languages I’ve tested.

RegExp – validate email

Here’s a regexp that validates email addresses – this is the most robust pattern I’ve seen, should work against any valid email.

Not sure why, but it fails in AS – at some point I’ll go through the whole thing and modify it to work with ActionScript, but for now I use a much […]

Flavored curry…

Here’s a few different takes on currying functions by extending the Function object, for JavaScript and ActionScript 2 (if using for ActionScript, use _global[“Function”].prototype instead of Function.prototype).

Flash Objects and Z-Index

If your flash object is overlaying other elements on your page, set the wmode param in the object markup to ‘opaque’

spend a few minutes on google if you want to know the internals – this post is just the upshot (!)