0 Replies Latest reply on Sep 12, 2007 2:06 PM by nickname_not_taken

    dissolve picture using bitmapData.pixelDissolve


      Code below should load a picture in a dissolved manner. It just seems to stop after one or a few of the 50 dissolve actions (timer is set to 50 times). If you want to run this code, make sure you have a picture correctly linked.


      package {
      import flash.display.Sprite;
      import flash.display.Loader;
      import flash.net.URLRequest;
      import flash.events.Event;
      import flash.geom.Matrix;
      import flash.display.BitmapData;
      import flash.display.Bitmap;
      import flash.utils.Timer;
      import flash.events.TimerEvent;
      import flash.geom.Rectangle;
      import flash.geom.Point;

      public class PixelDissolve0211 extends Sprite
      private var _bitmapData:BitmapData;
      private var _loader:Loader;
      private var _temporaryBitmapData:BitmapData;
      private var _timer:Timer;
      private var _randomValue:uint;

      public function PixelDissolve0211(){
      var bitmapData:BitmapData = new BitmapData( 250, 200, true, 0xFFFFFF);
      var bitmap:Bitmap = new Bitmap(bitmapData);
      _bitmapData = bitmapData;
      _loader = new Loader();
      _loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoad);
      var request:URLRequest = new URLRequest("file:///F|/Caplio/20070728/RIMG0311.JPG");
      _temporaryBitmapData = new BitmapData(250, 200, true, 0xFFFFFF);

      private function onLoad(event:Event):void{
      _temporaryBitmapData.draw(_loader, new Matrix(1,0,0,1));
      _timer = new Timer(50,50);
      _timer.addEventListener(TimerEvent.TIMER, onTimer);
      _randomValue = 0;

      private function onTimer(event:TimerEvent):void {
      _bitmapData.pixelDissolve(_temporaryBitmapData, new Rectangle(0,0, 250,200),new Point(0,0), _randomValue, 250*200/50);