By Zevan | April 22, 2009
1
2
| var sprite:Sprite = new Sprite();
addChild(sprite); |
Just testing a new highlighter… the site may have some weird issues for the next few minutes
UPDATE: Seems to be working, please let me know via the comments on this post if you see any code highlighting issues.
The new code highlighter won’t copy and paste line numbers into the timeline. For old posts you’ll still need to click the PLAIN TEXT button above each snippet.
By Zevan | December 27, 2008
Actionscript:
-
var canvas:BitmapData = new BitmapData(500, 500, true, 0xFFFFFFFF);
-
var color:BitmapData= new BitmapData(500, 500, true, 0x81666666);
-
var over:BitmapData = new BitmapData(500, 500, true, 0xFF000000);
-
addChild(new Bitmap(canvas, "auto", true));
-
var circle:Shape = new Shape();
-
circle.graphics.beginFill(0xFFFFFF,1);
-
circle.graphics.drawCircle(0,0,50);
-
var m:Matrix = new Matrix();
-
m.tx = 0;
-
m.ty = 1;
-
addEventListener(Event.ENTER_FRAME, onLoop);
-
function onLoop(evt:Event):void {
-
circle.x = mouseX;
-
circle.y = mouseY;
-
canvas.draw(circle, circle.transform.matrix);
-
canvas.copyPixels(color, color.rect, new Point(0,0), null, null, true);
-
over.copyPixels(canvas, canvas.rect, new Point(0,0), null, null, true);
-
canvas.draw(over, m, null, BlendMode.SCREEN);
-
over.applyFilter(over, over.rect, new Point(-2,-2), new BlurFilter(10,10,1));
-
canvas.draw(over, m, null, BlendMode.SUBTRACT);
-
}
Grayscale emboss technique. More info here.
By Zevan | November 20, 2008
Actionscript:
-
var image:Loader = new Loader();
-
image.load(new URLRequest("http://www.shapevent.com/sketchbook/wp-content/uploads/avalanche.jpg"));
-
image.x = stage.stageWidth / 2;
-
image.y = stage.stageHeight / 2;
-
addChild(image);
-
-
image.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
-
function onComplete(evt:Event):void {
-
-
// CENTER THE IMAGE
-
image.content.x = -image.content.width / 2;
-
image.content.y = -image.content.height / 2;
-
-
// BITMAP SMOOTHING
-
Bitmap(image.content).smoothing = true;
-
image.contentLoaderInfo.removeEventListener(Event.COMPLETE, onComplete);
-
}
-
-
-
// scale the image with the mouse to demonstrate smoothing and scaling from the center
-
addEventListener(Event.ENTER_FRAME, onLoop);
-
function onLoop(evt:Event):void {
-
image.scaleX = image.scaleY = mouseX / stage.stageWidth;
-
}
This is really two snippets combined. How to scale the content of a Loader from the center:
Actionscript:
-
// CENTER THE IMAGE
-
image.content.x = -image.content.width / 2;
-
image.content.y = -image.content.height / 2;
and how to smooth a jpg, png etc... that has been loaded dynamically into your swf:
Actionscript:
-
// BITMAP SMOOTHING
-
Bitmap(image.content).smoothing = true;