
Код AS3:
package view {
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Sprite;
import flash.geom.Point;
import flash.geom.Rectangle;
import resources.EmbedManager;
/**
*
* @author gloomyBrain
*/
public final class BlitWallScroller extends Sprite {
private var _sourceBD:BitmapData = null;
private var _viewBD:BitmapData = null;
private var _view:Bitmap = null;
private var _scroll:uint;
private var _maxScroll:uint;
private var _copyRect:Rectangle;
private var _destPoint:Point;
public function BlitWallScroller() {
super();
_sourceBD = EmbedManager.wall;
_viewBD = new BitmapData(_sourceBD.width, _sourceBD.height);
_view = new Bitmap(_viewBD);
_scroll = 0;
_maxScroll = _sourceBD.height;
_copyRect = new Rectangle(0, 0, _sourceBD.width);
_destPoint = new Point(0, 0);
super.addChild(_view);
}
/**
* @private
*/
public function update(value:uint):void {
value += _scroll;
if (value > _maxScroll) value %= _maxScroll;
_scroll = value;
_viewBD.lock();
if (value == 0) {
_destPoint.y = 0;
_copyRect.y = 0;
_copyRect.height = _maxScroll;
_viewBD.copyPixels(_sourceBD, _copyRect, _destPoint);
}else {
// верхняя часть
_destPoint.y = 0;
_copyRect.y = value;
_copyRect.height = _maxScroll - value;
_viewBD.copyPixels(_sourceBD, _copyRect, _destPoint);
// нижняя часть
_destPoint.y = _copyRect.height;
_copyRect.y = 0;
_copyRect.height = value;
_viewBD.copyPixels(_sourceBD, _copyRect, _destPoint);
}
_viewBD.unlock();
}
}
}
Вместо EmbedManager.wall нужно подставить свою BitmapData ну вызывать update по ENTER_FRAME