使用AS脚本实现两幅图片之间的消解过渡。
package {
import flash.display.Sprite;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.events.Event;
import flash.geom.Point;
public class Dissolve extends Sprite {
private var _bitmap:BitmapData;
private var _bitmap2:BitmapData;
private var _image:Bitmap;
private var _seed:Number;
private var _pixelCount: int = 0 ;
public function Dissolve( )
{
// Create a white rectangle
_bitmap = new BitmapData(stage.stageWidth,
stage.stageHeight,
false , 0xffffffff );
// Create a Black rectangle
_bitmap2 = new BitmapData(stage.stageWidth,
stage.stageHeight,
false , 0xff000000 );
// BitmapData object can not be displayed in the window,
// yet Bitmap is accepted.
_image = new Bitmap(_bitmap);
// Show the white rectangel
addChild(_image);
// set a random number to dissolve between the two bitmap
_seed = Math.random( ) * 100000 ;
// Begin dissolve when the frame show or say it when you enter the frame.
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
public function onEnterFrame( event :Event): void
{
// Copy 1000 random points from bitmap2 which is the destine bitmap to bitmap
// which is the start bitmap.
_seed = _bitmap.pixelDissolve(_bitmap2,
_bitmap.rect,
new Point( ),
_seed,
1000 );
_pixelCount += 1000 ;
// If we have copied all the points in bitmap2,remove the event.
if (_pixelCount > _bitmap.width * _bitmap.height) {
removeEventListener(Event.ENTER_FRAME,
onEnterFrame);
}
}
}
}
import flash.display.Sprite;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.events.Event;
import flash.geom.Point;
public class Dissolve extends Sprite {
private var _bitmap:BitmapData;
private var _bitmap2:BitmapData;
private var _image:Bitmap;
private var _seed:Number;
private var _pixelCount: int = 0 ;
public function Dissolve( )
{
// Create a white rectangle
_bitmap = new BitmapData(stage.stageWidth,
stage.stageHeight,
false , 0xffffffff );
// Create a Black rectangle
_bitmap2 = new BitmapData(stage.stageWidth,
stage.stageHeight,
false , 0xff000000 );
// BitmapData object can not be displayed in the window,
// yet Bitmap is accepted.
_image = new Bitmap(_bitmap);
// Show the white rectangel
addChild(_image);
// set a random number to dissolve between the two bitmap
_seed = Math.random( ) * 100000 ;
// Begin dissolve when the frame show or say it when you enter the frame.
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
public function onEnterFrame( event :Event): void
{
// Copy 1000 random points from bitmap2 which is the destine bitmap to bitmap
// which is the start bitmap.
_seed = _bitmap.pixelDissolve(_bitmap2,
_bitmap.rect,
new Point( ),
_seed,
1000 );
_pixelCount += 1000 ;
// If we have copied all the points in bitmap2,remove the event.
if (_pixelCount > _bitmap.width * _bitmap.height) {
removeEventListener(Event.ENTER_FRAME,
onEnterFrame);
}
}
}
}