scroll()方法
public function scroll(x:int, y:int):void
以一定的 (x, y) 像素量來捲動影像。 捲動區域外圍的邊緣區域維持不變。
BitmapData.colorTransform()
BitmapData.fillRect()
1010102_BitmapData.scroll.swf
var bmd:BitmapData = new BitmapData(550, 400, true, 0xFF0066CC); var rect:Rectangle = new Rectangle(0, 360, 40, 40); var bm:Bitmap = new Bitmap(bmd); addChild(bm); var ctf:ColorTransform = new ColorTransform(1, 1, 1, .88); var rec:Rectangle = new Rectangle(0,0,bmd.width,bmd.height); var offset:Number = 0; callTimer(30,18,loop); function callTimer(_delay:Number, _repeatCount:int, func:Function):void{ var timer:Timer = new Timer(_delay,_repeatCount); timer.addEventListener(TimerEvent.TIMER,func) timer.addEventListener(TimerEvent.TIMER_COMPLETE,completeHandler) timer.start(); } function loop(event:TimerEvent):void{ offset += 10; bmd.colorTransform(rec,ctf); bmd.scroll(offset, -offset+36); bmd.fillRect(rect, 0xFFFFFF00); } function completeHandler(event:TimerEvent):void{ event.currentTarget.removeEventListener(TimerEvent.TIMER,loop); event.currentTarget.removeEventListener(TimerEvent.TIMER_COMPLETE,completeHandler) offset = 0; callTimer(30,18,loop); }
沒有留言:
張貼留言