The game requires a lot of Bitmap text to increase the appearance. Recently, I also tried a simple experiment version. One of the ideas is to use the tweenlite endarray to refresh the bitmap and try to scroll through the number.
The basic class used is bitmap. The simplest and most direct method is to copy the pixel value.
The following is a simple experiment. You can try this simple effect.
package{import flash.display.Sprite;import com.greensock.TweenLite;import com.greensock.plugins.TweenPlugin; import com.greensock.plugins.EndArrayPlugin; import flash.events.MouseEvent;public class Main extends Sprite{private var rollText:RollTextField;public function Main(){TweenPlugin.activate([EndArrayPlugin]);rollText=new RollTextField();addChild(rollText);rollText.x=200;rollText.y=200;rollText.init(new nums(0,0),10);stage.addEventListener(MouseEvent.CLICK,onClick);}private function onClick(event:MouseEvent):void{rollText.text=Math.random()*5000;}}}
We can prepare numbers for the experiment materials. We need to divide the materials evenly so that each number can be averaged during cropping.
After making the video, preview it in Flash cc. You can prepare a digital clip for cropping and previewing at will.
package {import flash.display.Bitmap;import flash.display.BitmapData;import flash.display.Sprite;import flash.geom.Point;import flash.geom.Rectangle;import flash.text.TextField; import com.greensock.TweenLite; public class RollTextField extends Bitmap{private var source:BitmapData;private var w:int;private var h:int;private var rect:Rectangle;private var pt:Point;private var copyImg:BitmapData;private var curValue:int = 0;private var offX:int = 0;public var endFun:Function;public function RollTextField(){}public function init(source:BitmapData,len:int,offX:int=0):void{this.source = source;this.offX = offX;w = source.width / len;h = source.height;}public function set text(value:int):void{if (! source || value == curValue){return;}var myArray:Array = [curValue];this.curValue = value;if (! rect){rect = new Rectangle(0,0,w,h);}if (! pt){pt=new Point();}TweenLite.to(myArray, 1, {endArray:[value],onUpdate:onUpdateView,onComplete:onComplete});function onUpdateView():void{var myNewStr:String = String(int(myArray[0]));var len:int = myNewStr.length;if (copyImg){copyImg.dispose();copyImg = null;}copyImg =new BitmapData(len*w,h,true,0x0);for (var i:int=0; i<len; i++){var num:int = int(myNewStr.charAt(i)) + offX;rect.x = num * w;rect.y = 0;rect.width = w;rect.height = h;pt.x = i * w;pt.y = 0;copyImg.copyPixels(source,rect,pt);}bitmapData = copyImg;}function onComplete():void{if (endFun!=null){endFun.apply(null,null);}}}}}
Note: Recently, csdn images have been uploaded with watermarks, so I really want to try this boring setting.