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

throw tiles(training1)

Get Adobe Flash player
by byebeybye 10 Apr 2009
package {
    import flash.display.Sprite;
    import flash.events.*;

    [SWF(backgroundColor=0x020202, frameRate=60)]
    public class FlashTest extends Sprite{
        public var boad:SquareTiles;

        public function FlashTest(){
            boad = new SquareTiles(20);
            boad.x=233,boad.y=225;
            addChild(boad);
            addEventListener(Event.ENTER_FRAME,throwFromMouse)
        }
        
        private function throwFromMouse(event:Event):void{
            boad.throwTargetTile(mouseX/23,mouseY/23);         
        }

    }
}
 
import flash.display.Sprite;
import flash.events.*;

class SquareTiles extends Sprite {
    private var boxes:uint;
    public var tiles:Array = new Array();
    private var time:int=0;
    private var throwedSquare:uint = 0;
    private var tile:SSquare;

    public function SquareTiles(value:uint=20) {
        var i:uint=0;
        var j:uint=0;
        boxes = value;

        tiles= new Array();
        for(i=0; i <boxes; i++){
            tiles[i] = new Array();
        }
        for(i=0; i < boxes ;i++){
            for(j=0;j < boxes; j++){
                tile = new SSquare(uint(0xffffff - 0x010101*Math.ceil(255/(boxes)*j)));
                addChild(tile);
                tile.x = tile.startX = 13 + i*23 -23*boxes/2;
                tile.y = tile.startY = 13 + j*23 -23*boxes/2;
                tiles[i][j] = tile;
            }
        }
    }

//i,jを投げる
    public function throwTargetTile(i:uint=0,j:uint=0):void{

        var targetTile:SSquare;

        targetTile=tiles[i][j];          
        if(targetTile.startFlag==false){
            targetTile.startFlag=true;
            addChild(targetTile);
            targetTile.startThrow();
        }

    }
}


import flash.display.Sprite;
import flash.events.*;

class SSquare extends Sprite {
    public var time:uint=0;
    public var startX:int=0;
    public var startY:int=0;
    public var startFlag:Boolean = false;
    public var startVx:int=0;
    public var startVy:int=0;

    public function SSquare(color:int=0xffffff) {
            
        var tile:Sprite = new Sprite();
        tile.graphics.lineStyle(0,color,1,true);
        tile.graphics.beginFill(color);
        tile.graphics.drawRoundRect(-10,-10,20,20,3,3);

        addChild(tile);
    }

    public function startThrow():void{
        addEventListener(Event.ENTER_FRAME,throwSquare);
    }

    public function throwSquare(event:Event):void{
        time++;
        x = startVx*time+startX;
        y = time*time/12 +time*startVy+ startY;
        rotation= time*5;
    }
}