Posts Tagged ‘actionscript’

Custom tween in Tweener

Tuesday, August 18th, 2009

Custom Tween
I recently needed a tween that is different from the ones you see on the cheat sheet. All tweens you’ll find there have the property that the movement hardly goes outside the bounds of begin-to-endpoint (0…1). What I needed, was a tween that swings completely beyond its target, almost as far as the begin point (0…-1…1).

(more…)

Digging into CS4 perspective

Monday, July 13th, 2009

I finally managed to completely copy the flash internal perspective with a manual perspective.

CS4 perspective with manual perspective overlay in red

In flash cs4, you can make a plane, say, a 100×100 plane sitting on (0,0). Then, you can rotate it in 3D, using the properties rotationX, rotationY and rotationZ. Say you would rotate it by x and y by 20 degrees each, you end up with a nice plane in perspective.

Now this is really cool, but if would be quite a pain to display a 3D mesh in such a way.
(more…)

c# style trace

Tuesday, April 14th, 2009

Hi, just a little handy AS3 snippet I thought I’d share. It simulates the string.format from dotnet in a trace statement. I decided to name it tracef like printf in c (f = format)

tracef("my location = ({0}, {1}), my name is {2}", x, y, name)

Here’s the debug function:

private function tracef(msg:String, ...arguments):void
{
   for( var i:uint = 0; i < arguments.length; ++i )
   {
      msg = msg.split("{"+i+"}").join(arguments[i]);
   }
   trace( msg );
}

Btw, msg’s are bad for you, at least in your food, but that’s a different story.

Dynamic Textfield with custom font

Wednesday, February 18th, 2009

I noticed a little bug in flash (at least, in my version), for which I wanted to share the fix.

The bug is as follows: you create a TextField, you change it’s text and then it looks empty.

(more…)

Expected “Expected 1, got 0″, got “Expected 0, got 1″

Tuesday, February 17th, 2009

I got lost a bit today because I got the error message “Expected 0, got 1″ while trying to respond to a dispatchEvent. And because it’s such a weird error, and we need more posts about actionscript 3 programming on the web, I thought I’d share!

(more…)