I haven't posted in a while because i have been busy with other projects, which you will see soon.
I've decided to play with bitmapdata and see what it can be used for. I have used this effect in a game thats in production for the backgrounds because they look quite spacey. And its a quick way to get some awesome looking art without paying an artist.
First an example
You should see a blue/green image that looks quite good, something you might find in a game.
-
import flash.display.Bitmap;
-
import flash.display.BitmapData;
-
-
var seed:Number=Math.floor(Math.random()*100);
-
var channels:uint=BitmapDataChannel.BLUE|BitmapDataChannel.GREEN;
-
var myBitmapDataObject:BitmapData=new BitmapData(550,400,false, 0x00000000);
-
myBitmapDataObject.perlinNoise(100, 80, 6, seed, false, true, channels, false, null);
-
var myBitmap:Bitmap=new Bitmap(myBitmapDataObject);
-
addChild(myBitmap);
Line 1 and 2: Importing the necessary classes needed in this example.
line 4: This is a random number between 1 and 100 that we use when creating the bitmap with perlin noise. This number can be any number but varying it changes the pattern produced.
line 5: Bitmapdata has 4 channels, red blue green and alpha, you can mix channels by using "|". This is what the perlin noise is made up of.
line 6: Creating a black bitmapdata that fills the whole stage. The parameters are : BitmapData(width:int, height:int, transparent:Boolean = true, fillColor:uint = 0xFFFFFFFF)
line 7: Creating a perlin noise over the top of the bitmapdata that we just created. This is what makes those cool effects, play around with the values and see what you get. the parameters are: perlinNoise(baseX:Number, baseY:Number, numOctaves:uint, randomSeed:int, stitch:Boolean, fractalNoise:Boolean, channelOptions:uint = 7, grayScale:Boolean = false, offsets:Array = null).
line 8: Creating the bitmap that will hold the bitmapdata that i created before so that i can display it on stage. You cant add bitmapdata directly to the stage.
line 9: Adding the bitmap to the stage so we can see it.
And thats all for now, i will be experimenting with this later.


