Cache “nudger”

With web technologies generally, and flash specifically, managing cached assets can sometimes feel like walking a tightrope. If you’ve got a simple slideshow and have occasional updates to the image you want immediately reflected to the client, you’ll often see traditional “cache-busting” methods like appending a random number of the current UTC time to the […]

Understanding Easing (Explaining Penner’s equations) – JavaScript and ActionScript

Despite the commonality of the classic easing equations, largely attributed to Penner, there doesn’t seem to be the in-depth examination of “how it works” that a lot of code is subject to nowadays. First, a quick clarification on the most popular easing Classes. The “standard” easing classes (that provide predictable inertia), are Linear, Quad, Cubic, […]

PHP vs JS conditionals and ternary

Just a quick note about how PHP conditional operators differs from ECMA (JS and AS)… The double-pipe ‘OR’ operator, in JS, evaluated to the value of the expression that is not false. In PHP, it evaluates to true if any any expression is true, or false if not (the output will actually be “1” if […]

JS/AS – Cache your RegExp!

In both JavaScript and ActionScript, creating a regular expression – even using literal notation – results in the instantiation of a new RegExp object. If you’re going to use a pattern repeatedly (which is usually the case) – cache your patterns! Just like you would any other object – “literal” doesn’t mean “free”. Simple test […]

JS/AS Date Functions

A few date manipulation functions for JS/AS… Convert a MySQL DATE or DATETIME field into a valid JS/AS Date object:

UPDATE: Apparently FireFox can’t handle dashes when parsing the date. In the above replacement, use slashes instead:

Convert a JS Date Object to a MySQL formatted string

Get amount of time between […]

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. […]

AS3 – Casting objects

There seems to be some confusion amongst the community as to the details of casting objects to a class. There are two ways to do this: 1. Cast using the constructor… Constructor(obj); 2. Cast using the “as” operator… (obj as Constuctor); There are subtle yet significant differences between these two approaches. The first – passing […]

JS/AS – Number to Dollar Format

little proto to convert a number to currency, with dollar sign, commas and 2 decimal places…

or procedurally…

AS3 – Detect if JS really is available

ExternalInterface.available returns if the swf is in an environment capable of providing an external scripting engine – it does not detect whether JS is disabled. Here’s a quicky little function that will:

AS3 FileReference Upload Path Relativity (Bug?)

This behavior (dare I say: bug?) also relates to relative pathing when using a Video object’s load() method. See my post on that here. I’ll repeat some of the information found there, here. In AS3, normally an external file is pathed relative to the housing document (.html or .php, whatever). When supplying the url property […]