如何用Flash as3实现日全食的过程
今天在看《Essential ActionScript 3.0》,第26章一道文本溶解动画时,跟今天的日全食有点相似,由此想写如题的程序。
不过只是停留在想法,还要努力。
希望大家一起探讨具体方法。
复制内容到剪贴板代码:
package
{
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Sprite;
import flash.events.TimerEvent;
import flash.geom.Point;
import flash.geom.Rectangle;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.utils.Timer;
public class DissolveText extends Sprite
{
private var randomSeed:int = Math.floor(Math.random() * int.MAX_VALUE);
private var destPoint:Point = new Point(0, 0);
private var numberOfPixels:int = 10;
private var destColor:uint = 0xFF000000;
private var bitmapData:BitmapData;
private var t:Timer;
public function DissolveText()
{
createBitmap();
t = new Timer(100);
t.addEventListener(TimerEvent.TIMER, timerListener);
t.start();
}
private function timerListener(e:TimerEvent):void{
dissolve();
}
private function createBitmap():void{
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);
}
public function dissolve():void{
randomSeed = bitmapData.pixelDissolve(bitmapData, bitmapData.rect, destPoint, randomSeed, numberOfPixels, destColor);
var colorRegion:Rectangle = bitmapData.getColorBoundsRect(0xFFFFFFFF, destColor, false);
if(colorRegion.width == 0 && colorRegion.height == 0){
createBitmap();
t.start();
}
}
}
}
Word教程网 | Excel教程网 | Dreamweaver教程网 | Fireworks教程网 | PPT教程网 | FLASH教程网 | PS教程网 |
HTML教程网 | DIV CSS教程网 | FLASH AS教程网 | ACCESS教程网 | SQL SERVER教程网 | C语言教程网 | JAVASCRIPT教程网 |
ASP教程网 | ASP.NET教程网 | CorelDraw教程网 |