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

mX/mY/mZ

// forked from phi16's forked from: スロットみたいな動き方
// forked from rsakane's スロットみたいな動き方
/*
 * copyPixels()じゃなくて全部draw()で描いています。
 * なので、ちょっと重いです…。
 */
package
{
    import flash.display.AVM1Movie;
    import flash.display.Sprite
    import flash.events.Event;
    import flash.text.TextField;
    
    public class Main extends Sprite
    {
        private var mouseX1:Time;
        private var mouseX2:Time;
        private var mouseX3:Time;
        
        private var mouseY1:Time;
        private var mouseY2:Time;
        private var mouseY3:Time;
       
        private var Bx1:Number=0,Bx2:Number=0,Bx3:Number=0,By1:Number=0,By2:Number=0,By3:Number=0;
        
        public function Main()
        {    
            mouseX1 = new Time(10);
            mouseX1.y = (465 - mouseX1.height) / 2;
            mouseX1.x = 150;
            addChild(mouseX1);
            
            mouseX2 = new Time(10);
            mouseX2.y = mouseX1.y;
            mouseX2.x = 100;
            addChild(mouseX2);
            
            mouseX3 = new Time(10);
            mouseX3.y = mouseX1.y;
            mouseX3.x = 50;
            addChild(mouseX3);
            
            mouseY1 = new Time(10);
            mouseY1.y = mouseX1.y;
            mouseY1.x = 365;
            addChild(mouseY1);
            
            mouseY2 = new Time(10);
            mouseY2.y = mouseX1.y;
            mouseY2.x = 315;
            addChild(mouseY2);
            
            mouseY3 = new Time(10);
            mouseY3.y = mouseX1.y;
            mouseY3.x = 265;
            addChild(mouseY3);
            
            var mtfX:TextField = Text.createTextField("mouseX", 30, 0x0);
            mtfX.x = 70;
            mtfX.y = 300;
            addChild(mtfX);
            
            var mtfY:TextField = Text.createTextField("mouseY", 30, 0x0);
            mtfY.x = 290;
            mtfY.y = 300;
            addChild(mtfY);
            
            graphics.lineStyle(2.0);
            graphics.moveTo(0, mouseX1.y - 1);
            graphics.lineTo(465, mouseX1.y - 1);
            
            graphics.lineStyle(2.0);
            graphics.moveTo(0, mouseX1.y + 101);
            graphics.lineTo(465, mouseX1.y + 101);
            
            stage.addEventListener(Event.ENTER_FRAME, onMouseMove);
            onMouseMove();
        }
        
        private function onMouseMove(event:Event = null):void
        {            
            
            mouseX1.setTime(Bx1);
            mouseX2.setTime(Bx2);
            mouseX3.setTime(Bx3);
            
            mouseY1.setTime(By1);
            mouseY2.setTime(By2);
            mouseY3.setTime(By3);
            
            Bx1-=(Bx1-(int)(mouseX%10))/4;
            Bx2-=(Bx2-(int)(mouseX/10))/4;
            Bx3-=(Bx3-(int)(mouseX/100))/4;
            
            By1-=(By1-(int)(mouseY%10))/4;
            By2-=(By2-(int)(mouseY/10))/4;
            By3-=(By3-(int)(mouseY/100))/4;
            
            
        }
    }
}

import flash.display.Sprite;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.geom.Matrix;
import flash.geom.Rectangle;

class Time extends Sprite
{
    private static const SIZE:int = 50;
    
    private var max:int;
    private var bd:BitmapData;
    private var bitmap:Bitmap;
    
    public function Time(max:int)
    {
        this.max = max;
        
        bd = new BitmapData(SIZE, 100, true, 0x0);
        
        bitmap = new Bitmap(bd);
        addChild(bitmap);
    }
    
    public function setTime(n:Number):void
    {
        bd.fillRect(bd.rect, 0x0);
        //bd.fillRect(bd.rect, 0xFF000000);
        //bd.fillRect(new Rectangle(1, 1, bd.width - 2, bd.height - 2), 0xFFFFFFFF);
        
        var diff:Number = n - Math.round(n);
        var number:Number = Math.round(n) % max;
        
        var top:BitmapData = Text.textToBitmap(Text.createTextField(((number + 1) % max).toString(), SIZE, 0x0));
        var middle:BitmapData = Text.textToBitmap(Text.createTextField(number.toString(), SIZE, 0x0));
        var bottom:BitmapData = Text.textToBitmap(Text.createTextField((number == 0) ? (max - 1).toString() : (number - 1).toString(), SIZE, 0x0));
        
        var dy:Number = bd.height / 2 * diff;
        
        var matrix:Matrix = new Matrix();
        matrix.tx = (bd.width - middle.width) / 2;
        matrix.ty = (bd.height - middle.height) / 2 + dy;
        bd.draw(middle, matrix);
        
        matrix = new Matrix();
        matrix.tx = (bd.width - top.width) / 2;
        matrix.ty = -top.height / 2 + dy;
        bd.draw(top, matrix);
    
        matrix = new Matrix();
        matrix.tx = (bd.width - bottom.width) / 2;
        matrix.ty = bd.height - bottom.height / 2 + dy;
        bd.draw(bottom, matrix);
    }
}
 
class Text
{
    public static function createTextField(text:String, size:int, color:int):TextField
    {
        var tf:TextField = new TextField();
        tf.defaultTextFormat = new TextFormat("Ariel", size, color, true);
        tf.text = text;
        tf.autoSize = "left";
        tf.selectable = false;
 
        return tf;
    }
 
    public static function textToBitmap(tf:TextField, transparent:Boolean = true):BitmapData 
    {
        var bd:BitmapData = new BitmapData(tf.width, tf.height, transparent, 0x0);
        bd.draw(tf);
 
        return bd;
    }
}