Recently I found out this method to put pixel effect to your movieclip in AS2. Here goes the code:
//speed is in seconds
//_mc is the movieclip you want to apply pixel effect to
//pixel_from is the number of pixel to start, 1 is the original pixel size for every image
//pixel_target is the number of pixel to display at result
function pixelation(_mc:MovieClip, pixel_from:Number, pixel_target:Number, speed:Number) {
this.createEmptyMovieClip("pixelated_mc", 1 );
_mc._visible = false;
pixelated_mc._x = _mc._x;
pixelated_mc._y = _mc._y;
var pixelSize = pixel_from;
onEnterFrame = function(){
if (pixel_target > pixel_from) {
if (pixelSize >= pixel_target) {
pixelSize = pixel_target;
}
} else if (pixel_target < pixelsize =" pixel_target;" bitmapdata =" new" scalematrix =" new" _width =" _mc._width;" _height =" _mc._height;"> pixel_from) {
if (pixelSize == pixel_target) {
delete onEnterFrame;
}
pixelSize += (pixel_from*25)/speed;
} else if (pixel_target < pixel_from) {
if (pixelSize == pixel_target) {
delete onEnterFrame;
}
pixelSize -= (pixel_target*25)/speed;
} else {
pixelSize = pixel_target;
delete onEnterFrame;
}
}
}
// must try!
2 comments:
Hey, thanks for the code but mine fails and errors out when it gets to:
else if (pixel_target < pixelsize =" pixel_target;" bitmapdata =" new" scalematrix =" new" _width =" _mc._width;" _height =" _mc._height;"> pixel_from) {
The syntax doesn't appear to be right either. I don't know AS2 that well. any chance of a fix
For anybody who is interested, if the author doesn't post back, a similar effect can be found:
http://www.senocular.com/flash/source/?id=0.189
Post a Comment