Flash 8 Features
It's beyond the scope of this site to cover all of the features introduced in Flash 8, however, here are two features that I found to be of particular interest.
EXAMPLES BELOW REQUIRE FLASH PLAYER 8+.
Perlin Noise in Flash
Perlin noise is an algorithm that combines multiple random noise functions (or octaves) to create more natural random motion. The algorithm takes its name from its author, NYU's own Ken Perlin. It's likely that Macromedia recognized the popularity of this algorithm in Processing and decided to integrate it into Flash 8.
Be forewarned that using Perlin Noise can be processor intensive, hence I kept the example small.
In order to use Perlin Noise, we need to use Flash 8's BitmapData class. When using the BitmapData class (or bitmaps in general with Flash), we first create the bitmap by declaring a new BitmapData() object. After a new BitmapData object has been created, it needs to be attached to a MovieClip in order to display on the stage. Code is below:
/////////////////////////////////////////////////////////////
// IMPORT FLASH'S BUILT-IN CLASSES
/////////////////////////////////////////////////////////////
import flash.display.BitmapData;
import flash.geom.Point;
/////////////////////////////////////////////////////////////
// CREATE MOVIE ELEMENTS DYNAMICALLY
/////////////////////////////////////////////////////////////
// With the BitmapData class loaded, we create a new instance of BitmapData
var myBitmapData:BitmapData = new BitmapData(Stage.width, Stage.height, false, 0x00FF0000);
// Create a MovieClip to hold the bitmap
var mc:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
//Generate a random number for the perlin noise
var randomNum:Number = Math.floor(Math.random()*10);
// Attach the bitmap to the MovieClip
mc.attachBitmap(myBitmapData, this.getNextHighestDepth());
/////////////////////////////////////////////////////////////
// Here we create instances of Point from Flash's geom class.
// We'll use this array of points to create an offset for the
// Perlin Noise. This creates the effect of smooth motion
/////////////////////////////////////////////////////////////
var point1:Point = new Point(0, 0);
var point2:Point = new Point(50, 10);
var perlinOffset:Array = [point1, point2];
/////////////////////////////////////////////////////////////
// ONENTERFRAME FUNCTION
/////////////////////////////////////////////////////////////
mc.onEnterFrame = function() {
//increment the offset to create motion
perlinOffset[0].x += 10;
perlinOffset[1].y += 10;
myBitmapData.perlinNoise(200, 200, 20, randomNum, false, true, 5, false, perlinOffset);
};
Using ColorTransform in Flash 8
If you ever set the color of a MovieClip using ActionScript in Flash MX 2004 you probably remember doing something along the lines of:
var myColor:Color = new Color(targetMC);;
myColor.setRGB(0xFFFFFF)
While this still technically works in Flash 8, it has been deprecated in favor of the ColorTransform class. I've included the code below.
/////////////////////////////////////////////////////////////
// IMPORT FLASH'S BUILT-IN CLASSES
/////////////////////////////////////////////////////////////
import flash.geom.Transform;
import flash.geom.ColorTransform;
/* Below are two different examples of how to apply a color transform
* on a MovieClip. The first example (mc1) passes a green argument value of 255 into
* the constructor. The second example (mc2) references the last argument of the constructor
* directly (in this case, rgb), and provides a hexidecimal value.
*/
mc1.onPress = function() {
var tf:Transform = new Transform(this);
var color_tf:ColorTransform = new ColorTransform(0, 0, 0, 1, 0, 255, 0, 0);
tf.colorTransform = color_tf;
};
mc2.onPress = function() {
var tf:Transform = new Transform(this);
var color_tf:ColorTransform = new ColorTransform();
color_tf.rgb = 0xFF0000;
//trace("0x" + color_tf.rgb.toString(16)); // 0xff0000
tf.colorTransform = color_tf;
//trace(tf.colorTransform.toString()); //to get: (redMultiplier=0, greenMultiplier=1, blueMultiplier=1, alphaMultiplier=1, redOffset=0, greenOffset=0, blueOffset=255, alphaOffset=0)
};

