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

simple bitmap scroller

...
@author Jacky Riawan
Get Adobe Flash player
by Jacky.Riawan 07 Aug 2013
    Embed
/**
 * Copyright Jacky.Riawan ( http://wonderfl.net/user/Jacky.Riawan )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/dp27
 */

package  
{
    import flash.system.LoaderContext;
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.display.Loader;
    import flash.display.LoaderInfo;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.geom.Matrix;
    import flash.net.URLRequest;
    import flash.system.Security;
    /**
     * ...
     * @author Jacky Riawan
     */
    public class main extends Sprite
    {
        private const url:String = "";
        private var bitmapData:BitmapData
        private var matrix:Matrix = new Matrix();
        private var posx:Number = 0;
        private var posy:Number = 0;
        private var scale:Number = 1;
        private var speed:Number = 0;
        private var angle:Number = 0;
        private var targetAngle:Number = 0;
        private var timer:int = 0;
        private var targetScale:Number = 1;
        public function main() 
        {
            Security.allowDomain(url);
            var loader:Loader = new Loader();
            loader.load(new URLRequest(url),new LoaderContext(true));
            loader.contentLoaderInfo.addEventListener(Event.COMPLETE, doComplete);
        }
        
        private function doComplete(e:Event):void 
        {
            bitmapData = Bitmap(LoaderInfo(e.target).content).bitmapData;
            init();
        }
        
        private function init():void
        {
            addEventListener(Event.ENTER_FRAME, render);
        }
        
        private function render(e:Event):void 
        {
            if (timer == 0) {
                targetAngle=Math.random()*Math.PI*2;
                speed = 2 + Math.random() * 5;
                targetScale = .5 + Math.random();
                timer = 100 + Math.random() * 100;
            }else {
                timer--;
            }
            scale += (targetScale-scale) / 10;
            angle += (targetAngle-angle)/10;
            
            posx += Math.cos(angle)*speed;
            posy += Math.sin(angle) * speed;
            matrix = new Matrix(scale, 0, 0, scale, posx, posy);
            matrix.rotate(angle);
            graphics.clear();
            graphics.beginBitmapFill(bitmapData, matrix, true, true);
            graphics.drawRect(0, 0, 500, 500);
        }
        
    }

}