Posted By

adamcoulombe on 06/15/10


Tagged

actionscript pixel flash effect as3 halftone bender


Versions (?)

Who likes this?

6 people have marked this snippet as a favorite

fortes
shalomfriss
alptugan
tspitzr
Leang
mamzellejuu


Halftone Effect in Actionscript 3 / Flash


 / Published in: ActionScript 3
 

URL: http://www.adamcoulombe.info/lab/as3/halftone/

This is a demo of a halftone effect for AS3. It requires a halftone filter file. You can download all the files required for this at http://www.adamcoulombe.info/lab/as3/halftone/

  1. package
  2. {
  3. import flash.display.*;
  4. import flash.events.*;
  5. import flash.filters.*;
  6. import flash.net.*;
  7.  
  8.  
  9.  
  10. public class Halftone extends Sprite
  11. {
  12.  
  13. private var image:Class;
  14.  
  15. private var loader:URLLoader;
  16. private var shader:Shader;
  17. private var filter:ShaderFilter;
  18. private var im:Bitmap;
  19.  
  20. public function Halftone():void
  21. {
  22. var myImage = new MyImage(500,333);
  23. im = new Bitmap(myImage);
  24. addChild(im);
  25. loader = new URLLoader();
  26. loader.dataFormat = URLLoaderDataFormat.BINARY;
  27. loader.addEventListener(Event.COMPLETE, onComplete);
  28. loader.load(new URLRequest("Halftone.pbj")); //Download: http://www.adamcoulombe.info/lab/as3/halftone/Halftone.pbj
  29. }
  30.  
  31. private function onComplete(e:Event):void
  32. {
  33. stage.addEventListener(MouseEvent.MOUSE_MOVE,mouseMoved)
  34.  
  35. }
  36. private function mouseMoved(e):void
  37. {
  38. shader = new Shader(loader.data);
  39. //shader.data.contrast.value = [ 1 ] ;
  40. shader.data.brightness.value = [ stage.mouseX /stage.stageWidth + 1 ];
  41. //shader.data.amount.value = [100];
  42. filter = new ShaderFilter(shader);
  43. im.filters = [filter];
  44. }
  45. }
  46. }

Report this snippet  

You need to login to post a comment.