Pixelate Image
Posted On: August 25, 2009
Price: Free!
Flash Player Version: 8
Swishmax Version: Swishmax 2, 2008.08.12
Comments: One comment
Price: Free!
Flash Player Version: 8
Swishmax Version: Swishmax 2, 2008.08.12
Comments: One comment

54 downloads
Original script by Senocular.
This file shows an image being pixelated by varying amounts over time using the BitmapData in Flash 8.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | onFrame (1) { // create a movie clip to contain pixelated verson // of the image in original_mc this.createEmptyMovieClip( "pixelated_mc", 1 ); // place it below original_mc pixelated_mc._x = original_mc._x + original_mc._width; pixelated_mc._y = original_mc._y; // function pixelate = function(){ // create a variable to represent the current pixel size var pixelSize = 80; // hide repeat button repeat._visible = false; // every frame, increase pixelation this.onEnterFrame = function(){ // create a new bitmapData object based on original // movie clip size and current pixel size. This will // be used to pixelate the original var bitmapData = new flash.display.BitmapData( original_mc._width/pixelSize, original_mc._height/pixelSize, false ); // attach the bitmap to pixelated_mc pixelated_mc.attachBitmap(bitmapData, 1); // create a matrix object used to scale the image // which will be drawn from the original to bitmapData var scaleMatrix = new flash.geom.Matrix(); // scale based on pixelSize scaleMatrix.scale(1/pixelSize, 1/pixelSize); // draw the original in BitmapData object at its reduced size bitmapData.draw( original_mc, scaleMatrix ); // assure pixelated_mc matches the size of original_mc pixelated_mc._width = original_mc._width; pixelated_mc._height = original_mc._height; // increase pixelation pixelSize *= .95; // if pixel size is larger enough, delete function if (pixelSize < 1){ delete this.onEnterFrame; // show repeat button repeat._visible = true; } } } // initiate the function pixelate(); // on release function for repeat button repeat.onRelease = function(){ pixelate(); } stop(); } |


Luv this one!