Category Archives: Uncategorized

Testing New Code Highlighter

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.

Posted in Uncategorized | Leave a comment

Blendmode Emboss

Actionscript:
  1. var canvas:BitmapData = new BitmapData(500, 500, true, 0xFFFFFFFF);
  2. var color:BitmapData= new BitmapData(500, 500, true, 0x81666666);
  3. var over:BitmapData = new BitmapData(500, 500, true, 0xFF000000);
  4. addChild(new Bitmap(canvas, "auto", true));
  5. var circle:Shape = new Shape();
  6. circle.graphics.beginFill(0xFFFFFF,1);
  7. circle.graphics.drawCircle(0,0,50);
  8. var m:Matrix = new Matrix();
  9. m.tx = 0;
  10. m.ty = 1;
  11. addEventListener(Event.ENTER_FRAME, onLoop);
  12. function onLoop(evt:Event):void {
  13.     circle.x = mouseX;
  14.     circle.y = mouseY;
  15.     canvas.draw(circle, circle.transform.matrix);
  16.     canvas.copyPixels(color, color.rect, new Point(0,0), null, null, true);
  17.     over.copyPixels(canvas, canvas.rect, new Point(0,0), null, null, true);
  18.     canvas.draw(over, m, null, BlendMode.SCREEN);
  19.     over.applyFilter(over, over.rect, new Point(-2,-2), new BlurFilter(10,10,1));
  20.     canvas.draw(over, m, null, BlendMode.SUBTRACT);
  21. }

Grayscale emboss technique. More info here.

Posted in Uncategorized | Tagged , | Leave a comment

Loader, Centering, Smoothing

Actionscript:
  1. var image:Loader = new Loader();
  2. image.load(new URLRequest("http://www.shapevent.com/sketchbook/wp-content/uploads/avalanche.jpg"));
  3. image.x = stage.stageWidth / 2;
  4. image.y = stage.stageHeight / 2;
  5. addChild(image);
  6.  
  7. image.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
  8. function onComplete(evt:Event):void {
  9.    
  10.     // CENTER THE IMAGE
  11.     image.content.x = -image.content.width / 2;
  12.     image.content.y = -image.content.height / 2;
  13.    
  14.     // BITMAP SMOOTHING
  15.     Bitmap(image.content).smoothing = true;
  16.     image.contentLoaderInfo.removeEventListener(Event.COMPLETE, onComplete);
  17. }
  18.  
  19.  
  20. // scale the image with the mouse to demonstrate smoothing and scaling from the center
  21. addEventListener(Event.ENTER_FRAME, onLoop);
  22. function onLoop(evt:Event):void {
  23.     image.scaleX = image.scaleY = mouseX / stage.stageWidth;
  24. }

This is really two snippets combined. How to scale the content of a Loader from the center:

Actionscript:
  1. // CENTER THE IMAGE
  2. image.content.x = -image.content.width / 2;
  3. image.content.y = -image.content.height / 2;

and how to smooth a jpg, png etc... that has been loaded dynamically into your swf:

Actionscript:
  1. // BITMAP SMOOTHING
  2. Bitmap(image.content).smoothing = true;

Posted in Uncategorized | 3 Comments