Forked from: actionscriptbible's Chapter 36 Example 1 diff:25 Chapter 36 Example 3 actionscript.. forked:4favorite:4lines:38license : MIT License modified : 2010-02-09 14:19:52 Embed Tweet package { import flash.display.*; import flash.events.Event; import flash.geom.*; import flash.net.URLRequest; import flash.system.LoaderContext; [SWF(frameRate="10")] public class ch36ex3 extends Sprite { protected const SIZE:Rectangle = new Rectangle(0, 0, 48, 48); protected var TOTALFRAMES:int; protected var bmp:BitmapData; protected var filmstrip:BitmapData; protected var frame:int = 0; protected var sourceRect:Rectangle = SIZE.clone(); public function ch36ex3() { var loader:Loader = new Loader(); //Animation by Derek Yu - www.derekyu.com - used with permission loader.load( new URLRequest("http://actionscriptbible.com/files/monkey.png"), new LoaderContext(true)); loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoad); bmp = new BitmapData(SIZE.width, SIZE.height); var bitmap:Bitmap = new Bitmap(bmp, PixelSnapping.ALWAYS, false); bitmap.scaleX = bitmap.scaleY = 4; addChild(bitmap); } protected function onLoad(event:Event):void { filmstrip = Bitmap(LoaderInfo(event.target).content).bitmapData; TOTALFRAMES = filmstrip.width / SIZE.width; addEventListener(Event.ENTER_FRAME, onEnterFrame); } protected function onEnterFrame(event:Event):void { frame = ++frame % TOTALFRAMES; sourceRect.x = frame * SIZE.width; bmp.fillRect(bmp.rect, 0); bmp.copyPixels(filmstrip, sourceRect, new Point(0,0)); } } } Code Fullscreen Preview Fullscreen FTMSuperfly Giggle Dorara Wolfe : animationsprite animation as3bible atlas bitmapdata sheet sprite frame frame PixelSnapping.ALWAYS PixelSnapping.ALWAYS width width Rectangle Rectangle scaleY scaleY scaleX content scaleX clone content Bitmap clone copyPixels Bitmap LoaderContext sort new page view favorite forked pv165 forked from: Chapter 36 Exampl.. bostoncomputer forked:1 favorite:0lines:38 (diff:3) pv301 forked from: Chapter 36 Exampl.. Alex.Rincon forked:0 favorite:2lines:38 (diff:2) pv179 forked from: Chapter 36 Exampl.. 4cesliv forked:0 favorite:0lines:38 (diff:2) pv372 forked from: Chapter 35 Exampl.. mycyberplanet forked:1 favorite:0lines:38 (diff:1)