t810049 (3)

by ProjectNya
♥0 | Line 66 | Modified 2011-06-23 18:37:58 | MIT License
play

ActionScript3 source code

/**
 * Copyright ProjectNya ( http://wonderfl.net/user/ProjectNya )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/aeKB
 */

////////////////////////////////////////////////////////////////////////////////
// t810049 (3)
////////////////////////////////////////////////////////////////////////////////

package {

    import flash.display.Sprite;
    import flash.display.StageScaleMode;
     import flash.display.StageAlign;
    import flash.display.Shape;
     import flash.events.Event;

    [SWF(backgroundColor="#FFFFFF", width="465", height="465", frameRate="30")]

    public class Main extends Sprite {
        private static var max:uint = 3;
        private var imgs:Array;
        private var img1:Sprite;
        private var img2:Sprite;
        private var img3:Sprite;
        private static var sx:int = 132 - 200;
        private static var tx:int = sx + 600;
        private static var speed:int = 5;

        public function Main() {
            //Wonderfl.capture_delay(1);
            stage.scaleMode = StageScaleMode.NO_SCALE;
            stage.align = StageAlign.TOP_LEFT;
            init();
        }

        private function init():void {
            img1 = new Sprite();
            addChild(img1);
            img1.graphics.beginFill(0xFF0000);
            img1.graphics.drawRect(0, 0, 200, 130);
            img1.graphics.endFill();
            img1.x = sx;
            img1.y = 232 - 65;
            //
            img2 = new Sprite();
            addChild(img2);
            img2.graphics.beginFill(0xFFFF00);
            img2.graphics.drawRect(0, 0, 200, 130);
            img2.graphics.endFill();
            img2.x = sx + 200;
            img2.y = 232 - 65;
            //
            img3 = new Sprite();
            addChild(img3);
            img3.graphics.beginFill(0x0000FF);
            img3.graphics.drawRect(0, 0, 200, 130);
            img3.graphics.endFill();
            img3.x = sx + 400;
            img3.y = 232 - 65;
            //
            var overlay:Shape = new Shape();
            addChild(overlay);
            overlay.graphics.beginFill(0x000000, 0.5);
            overlay.graphics.drawRect(0, 0, 200, 465);
            overlay.graphics.endFill();
            overlay.x = 132;
            //
            imgs = new Array();
            imgs.push(img1);
            imgs.push(img2);
            imgs.push(img3);
            //
            addEventListener(Event.ENTER_FRAME, update, false, 0, true);
        }
        private function update(evt:Event):void {
            for (var n:uint = 0; n < max; n++) {
                var img:Sprite = imgs[n];
                img.x += speed;
                if (img.x >= tx) {
                    img.x = sx;
                }
            }
        }

    }

}