In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

無限スクロール

目が回る
Get Adobe Flash player
by shohei909 08 Sep 2011
    Embed
/**
 * Copyright shohei909 ( http://wonderfl.net/user/shohei909 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/gBjt
 */

package {
    import flash.system.LoaderContext;
    import flash.events.Event;
    import flash.net.URLRequest;
    import flash.display.Loader;
    import flash.display.Sprite;
    [SWF(frameRate="60")]
    public class FlashTest extends Sprite {
        private var loader:Loader = new Loader();
        private var scroll:ScrollBitmap;
        function FlashTest() {
            loader.load( new URLRequest("http://assets.wonderfl.net/images/related_images/6/63/635d/635d81aa6aee53fd6dc42404398e20421aad6567" ), new LoaderContext(true));
            loader.contentLoaderInfo.addEventListener( "complete", onLoad );
        }
        private function onLoad(e:Event):void {
            loader.contentLoaderInfo.removeEventListener( "complete", onLoad );
            addChild( scroll = new ScrollBitmap( loader, 465, 465, loader.width, loader.height ) )
            addEventListener( "mouseMove", mouseMove );
            mouseMove();
        }
        private function mouseMove( e:Event = null ):void{
            scroll.dx = (mouseX - 233) * 0.03;
            scroll.dy = (mouseY - 233) * 0.03;
        }
    }
}
import flash.display.Graphics;
import flash.events.Event;
import flash.geom.Point;
import flash.geom.Matrix;
import flash.display.IBitmapDrawable;
import flash.display.BitmapData;
import flash.display.Sprite;
class ScrollBitmap extends Sprite{
    public var dx:Number = 2, dy:Number = 2;
    public var h:Number, w:Number;
    public var dh:Number, dw:Number;
    public var scrollX:Number = 0;
    public var scrollY:Number = 0;
    private var bitmap:BitmapData; 
    function ScrollBitmap( drawable:IBitmapDrawable, w:int, h:int, dw:int, dh:int ){
        this.dh = dh; this.dw = dw; this.h = h; this.w = w;
        bitmap =  new BitmapData( dw, dh, false, 0 );
        bitmap.draw( drawable )
        addEventListener( "exitFrame", onFrame );
    }
    public function onFrame( e:Event ):void{
        scrollX += dx; scrollY += dy;
        if( scrollX > 0 ){ scrollX -= dw }
        if( scrollX < -dw ){ scrollX += dw }
        if( scrollY > 0 ){ scrollY -= dh }
        if( scrollY < -dh ){ scrollY += dh }
        var g:Graphics = graphics;
        g.clear();
        g.beginBitmapFill( bitmap, new Matrix( 1, 0, 0, 1, scrollX, scrollY ), true, false );
        g.drawRect(0,0,w,h);
    }
}