Rasterizing, then dissolving a TextField : Effects « TextField « Flash / Flex / ActionScript

Home
Flash / Flex / ActionScript
1.Animation
2.Array
3.Class
4.Data Type
5.Development
6.Function
7.Graphics
8.Language
9.Network
10.Regular Expressions
11.Statement
12.String
13.TextField
14.XML
Flash / Flex / ActionScript » TextField » Effects 
Rasterizing, then dissolving a TextField
 
package {
  import flash.display.*;
  import flash.utils.*;
  import flash.events.*;
  import flash.geom.*;
  import flash.text.*;

  public class DissolveText extends Sprite {
    private var randomSeed:int = Math.floor(Math.random(  ) int.MAX_VALUE);
    private var destPoint:Point = new Point(00);
    private var numberOfPixels:int 10;
    private var destColor:uint = 0xFF000000;

    private var bitmapData:BitmapData;
    private var t:Timer;

    public function DissolveText (  ) {
      var txt:TextField = new TextField(  );
      txt.text = "Essential ActionScript 3.0";
      txt.autoSize = TextFieldAutoSize.LEFT;
      txt.textColor = 0xFFFFFF;

      bitmapData = new BitmapData(txt.width, txt.height, false, destColor);
      bitmapData.draw(txt);

      var bitmap:Bitmap = new Bitmap(bitmapData);
      addChild(bitmap);

      t = new Timer(10);
      t.addEventListener(TimerEvent.TIMER, timerListener);
      t.start(  );
    }

    private function timerListener (e:TimerEvent):void {
      dissolve(  );
    }

    public function dissolve(  ):void {
      randomSeed = bitmapData.pixelDissolve(bitmapData,
                                            bitmapData.rect,
                                            destPoint,
                                            randomSeed,
                                            numberOfPixels,
                                            destColor);
      var coloredRegion:Rectangle =
                bitmapData.getColorBoundsRect(0xFFFFFFFF, destColor, false);
      if (coloredRegion.width == && coloredRegion.height == ) {
        t.stop(  );
      }
    }
  }
}

        
Related examples in the same category
1.Applying Advanced Anti-Aliasing
2.Make whole TextField italic
3.Set Text box grid fit type to pixel
4.ClickableText
5.the text appears fully opaque, even though the text field's alpha percentage is set to 20%:
6.a list of bulleted text
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.