Flash Flash Everywhere

I would by no means call myself anything more than a ‘novice’ at programming with Actionscript; it’s not something I have volumes of experience in, outside of the program I took in college. I swore I’d never work on another Flash project after my last class, and a couple weeks later I was at a 3-day Flex training course.  To continue the trend, I’ve been doing quite a lot of Actionscript (3) at work for the past month or so at work, making interactive maps (eep!) — I’ve been called ‘the map guy’ by some because of it.

HENCE ALL THE ACTIONSCRIPT 3 RELATED POSTS.

Indeed, I had set up a separate blog to keep track of the little nuances/annoyances I learned (and that I’m still learning!) while reading and programming in AS3. Then I realized it was a waste of time to maintain another blog and promptly merged it with this one. Funny how things work out … 

Tinting a Display Object

Tinting a display object in AS3 is remarkably easy:

// EXAMPLE 1: tint a display object
import fl.motion.Color;
// [..]
var tint:Color = new Color();
tint.setTint( 0x0099ff, 1 );
myobject.transform.colorTransform = tint;

You’ve got two options for resetting the colour, store the original colour or create a new Color object. The following example resets the colour of a display object when it is hovered over.

// EXAMPLE 2: reset with a new Color Object
import fl.motion.Color;
import flash.events.MouseEvent;
// [..]

// call the hover() function when we hover over the display object:
myobject.addEventListener(MouseEvent.ROLL_OVER, hover);

private function hover(e:MouseEvent):void{
    e.currentTarget.transform.colorTransform = new Color(); // removes tint
}

Alternatively, you can store the original “colour” of the untinted in a variable before you tint it. The following trivial example demonstrates this, but you wouldn’t see any visible change on the stage (FYI).

// EXAMPLE 3: reset the tint by storing the original value
import fl.motion.Color;
// [..]
var tint:Color = new Color();
tint.setTint( 0x0099ff, 1 );

var originalColour:Color = myobject.transform.colorTransform; // store the original colour.

myobject.transform.colorTransform = tint; // tint the object blue
myobject.transform.colourTransform = originalColour; // tint the object back to its original colour

Updating Slice Software

This is one of those things that I don’t do often enough to commit to memory, so for future reference:

sudo aptitude update; #updates source repositories
sudo aptitude safe-upgrade;
sudo aptitude full-upgrade;
#tada!