Good news for those, who want to get familiar with physics engine Box2DFlashAS3! Somebody has translated manual from C++ to ActionScript 3.0 so now it’s much easier to comprehend.
It’s here
http://www.adobe.com/products/flashplayer/
My company have recently bought a flip book component from flashpageflip.com. In a nutshell - don’t buy this crap! This is one of the worst code samples I’ve ever seen. What’s more this “component” doesn’t even work when loaded to another swf file. Here’s some code from the fla file (of course it’s ActionScript 1.0, not 2.0 as they say on the site)
//load first page
if(eval("_root.pages.p4.page.pf.ph.pic.p"+(_root.page+1)).Page.doneLoading!=true){
eval("_root.pages.p4.page.pf.ph.pic.p"+(_root.page+1)).Page.loadMovie(_root.pageNames[_root.page]);
}
//...
pageClips = new Array();
pageClips[1] = pages.p1.page.pf.ph.pic;
pageClips[2] = pages.flip.p2.page.pf.ph.pic;
pageClips[3] = pages.flip.p3.page.pf.ph.pic;
pageClips[4] = pages.p4.page.pf.ph.pic;
Quick peek at timeline:

So if anyone asks you if it’s worth buying you have your answer above.
I’ve just bought a ticket for FITC 2009.
Super early bird pricing ends 18.X , so if you’re a student buy a ticket now, since it’s only 130 euro (comparing to Adobe MAX this is freaking cheap)
Today I’m gonna show you how to make a simple mouse avoiding algorithm. Check out the example below:

We’re gonna run quickly through the code:
package {
import flash.display.Sprite;
import flash.events.Event;
import flash.geom.Point;
public class MouseAvoider extends Sprite {
private const DISTANCE_DIVISOR:uint = 10; //see moveToDestination()
private const FRICTION:Number= .9;
private const FEAR_DISTANCE:Number= 150; //if mouse gets closer than this value sprite moves away
private const MAX_AVOID_FORCE:uint = 10; //maximum length of avoid vector
private var _destinationPoint:Point; //destination point
private var _speed:Point = new Point(0, 0); //speed vector
public function MouseAvoider():void {
drawStuff();
}
private function drawStuff():void {
graphics.beginFill(Math.random() * 0xFFFFFF)
graphics.drawCircle(0, 0, 10);
graphics.endFill();
}
public function set destinationPoint(value:Point):void {
_destinationPoint = value;
addEventListener(Event.ENTER_FRAME, move);
}
protected function move(e:Event):void {
moveToDestination();
avoidMouse();
applyFriction();
updatePosition();
}
private function moveToDestination():void {
_speed.x += (_destinationPoint.x - x) / DISTANCE_DIVISOR;
_speed.y += (_destinationPoint.y - y) / DISTANCE_DIVISOR;
}
private function avoidMouse():void{
var currentPosition:Point = new Point(x, y);
var mousePosition:Point = new Point(stage.mouseX, stage.mouseY);
var distance:uint = Point.distance(currentPosition, mousePosition);
if (distance < FEAR_DISTANCE) {
var force:Number = (1 - distance / FEAR_DISTANCE) * MAX_AVOID_FORCE;
var gamma:Number = Math.atan2(-mousePosition.y + currentPosition.y, -mousePosition.x + currentPosition.x);
var avoidVector:Point = Point.polar(force, gamma);
_speed.x += avoidVector.x;
_speed.y += avoidVector.y;
}
}
private function applyFriction():void {
_speed.x *= FRICTION;
_speed.y *= FRICTION;
}
private function updatePosition():void{
x += _speed.x;
y += _speed.y;
}
}
}
_speed is a Point class instance in which we store speed vector components (the x-axis speed and the y-axis speed). I use Point because it has some interesing static functions, which might be helpful time-to-time
- drawStuff function draws a random color circle in our sprite.
- destinationPoint setter initalizes the algorithm and sets Event.ENTER_FRAME handler.
- move function launches one-by-one four functions:
- moveToDestination makes our object move to destinationPoint we previously set.
- avoidMouse - if distance between out object and mouse is less than FEAR_DISTANCE constant this function forces sprite to move away from pointer.
var force:Number = (1 - distance / FEAR_DISTANCE) * MAX_AVOID_FORCE;
var gamma:Number = Math.atan2(-mousePosition.y + currentPosition.y, -mousePosition.x + currentPosition.x);
var avoidVector:Point = Point.polar(force, gamma);
force is length of avoidVector. The closer the mouse, the larger the force.
Math.atan2() counts direction in radians of avoidVector
Point.polar() function given length and direction of vector returns a Point with it’s components. This is extremly useful for those, who don’t want to play with trigonometry.
- applyFriction - multiplies speed vector by FRICTION, if we don’t apply this out sprite would act as a pendulum in no-friction enviroment (without this sprite would never stop)
- updatePosition adds speed vector to sprite position.
Hope you gonna like it
Here’s the source of example.

Instead of working (hope my boss does not read this) I’ve developed FlashChat (credits go to mooska for an idea), which is installed as a regular panel in Flash CS3. It’s not something to be very proud of, since FMS is pretty easy, however it’s a nice app if you’re trying to pretend you work and chat with friends
Enjoy!
Kindisoft has just released SecureSWF 3.0. This is a very powerful ActionScript 3.0 obfuscator. Take a look at it’s features. To be honest I didn’t test it yet but it’s possibilities are very promising:
Decompilers Stopping Power:
secureSWF stops all known decompilers and disassemblers using the following advanced mechanisms:
* Control flow obfuscation.
* Dynamic code wrapping.
* Statement-level randomization.
String Encryption.
secureSWF helps you protect your Flash and Flex application from variety of security threats by providing literal strings encryption.
Access Limitation:
secureSWF limits access to your published SWF files through:
* Encrypted domain locks.
* Encrypted loader creation.
I was given link to this fantastic blog about ActionScript 3.0 design patterns. Enjoy 
Perhaps most of you know how to convert BitmapData to JPG, BMP or PNG ByteArray. If not take a look at Adobe CoreLib Project. I’ll show you now how you can convert ByteArray back to BitmapData, which can be useful if you for example want to store several images on the server in a single file.
package {
import encoding.JPGEncoder;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Loader;
import flash.display.Sprite;
import flash.utils.ByteArray;
import flash.events.Event
public class Converter extends Sprite {
[Embed(source = "image.jpg")]
private var image:Class
private const QUALITY:uint = 80;
public function Converter():void {
var bitmap:Bitmap = new image();
var bitmapData:BitmapData = bitmap.bitmapData;
//encode BitmapData to JPG
var encoder:JPGEncoder = new JPGEncoder(QUALITY);
var rawBytes:ByteArray = encoder.encode(bitmap.bitmapData);
//decode JPG ByteArray back to BitmapData
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, getBitmapData)
loader.loadBytes(rawBytes);
}
private function getBitmapData(e:Event):void {
var decodedBitmapData:BitmapData = Bitmap(e.target.content).bitmapData
trace(decodedBitmapData);
}
}
}
Rembember than loadBytes() can load ByteArray with JPG, BMP, PNG, or SWF and that you can easily encrypt ByteArray instance with as3crypto library. This trick can be extremly helpful when trying to obfuscate code.
Recenently I’ve developed this Magma Effect:

This effect is using so-called metaballs (or blobbies), which are pretty hard to code using math. What you see up there is a cheap trick, however it works and looks sexy 
Magma Effect was achieved using red balls simulated by Box2DFlashAS3 engine, which in my oppinion is the best avaible physics engine for ActionScript 3.0.
First step is to create a sprite with red circle inside. This is a base of your metaball. You can see what’s behind the scene of Magma Effect here (single click launches ShadowBox, don’t open it in new tab).
It doesn’t look much like magma, right? This is why the balls are blurred in the next step. To do this you have to apply the BlurFilter to the sprite which contains all the balls (or each ball independently). It’s important to use medium or even high quality (third argument of BlurFilter class constructor). Low quality makes the metaballs look like squares. According to Help blurX and blurY values that are power of 2 are optimized to render more quickly, so I recommend you to use value of 32 or 64. Blurred balls should look something like this.
Last step is to draw the container into BitmapData object and use the BitmapData.threshold function. You can read how exactly this function works in tutorial on sepiroth.it. After this operation your shiny new metaballs are ready to use.
Here is simple example:
package {
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Sprite;
import flash.filters.BlurFilter;
import flash.filters.BitmapFilterQuality;
import flash.geom.Point;
import flash.geom.Rectangle;
[SWF(width = 300, height = 200, framerate = 31)]
public class Metaballs extends Sprite {
public var container:Sprite = new Sprite();
public var bitmap:Bitmap;
public var bitmapData:BitmapData;
public function Metaballs():void {
for (var i:uint = 0; i < 10; i++) {
var radius:uint = Math.round(Math.random() * 30 + 10);
var circle:Sprite = getRedCircle(radius);
circle.x = Math.random() * stage.stageWidth;
circle.y = Math.random() * stage.stageHeight;
container.addChild(circle);
}
container.filters = [new BlurFilter(32, 32, BitmapFilterQuality.MEDIUM)];
//draw to bitmap:
bitmapData = new BitmapData(stage.stageWidth, stage.stageHeight, false);
bitmap = new Bitmap(bitmapData.clone());
bitmapData.draw(container);
var bounds:Rectangle = new Rectangle(0, 0, stage.stageWidth, stage.stageHeight);
var zeroPoint:Point = new Point(0, 0);
bitmap.bitmapData.threshold(bitmapData, bounds, zeroPoint, "<=", 0x00ee00, 0xFFFF0000, 0x0000FF00, false)
addChild(bitmap);
}
private function getRedCircle(radius:Number):Sprite {
var circle:Sprite = new Sprite();
circle.graphics.beginFill(0xff0000);
circle.graphics.drawCircle(0, 0, radius);
circle.graphics.endFill();
return circle;
}
}
}