Matrixの練習

by hacker_szoe51ih
♥0 | Line 45 | Modified 2010-07-07 23:18:12 | MIT License
play

ActionScript3 source code

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

package {
    import flash.events.MouseEvent;
    import flash.events.Event;
    import flash.geom.Matrix;
    import flash.geom.Transform;
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
        [SWF(width=465,height=465,backgroundColor=0,frameRate=30)]
        
        public var myBox:Particle;
        public var myTransform:Transform;
        public var mtx:Matrix; 
        public var centerX:Number=stage.stageWidth/2;
        public var centerY:Number=stage.stageHeight/2;
        //public var nRadian:Number;
        
        public function FlashTest() {
        
                init();
            
        }
        
        public function init():void{
        
            myBox=new Particle();
            addChild(myBox);
          
           
            myTransform=myBox.transform;
           
            
            stage.addEventListener(MouseEvent.CLICK,onEnterFrame);
        
        }
        
        public function onEnterFrame(e:MouseEvent):void{
            
            var mtx2:Matrix=new Matrix();            
            //var nRadian:Number=Math.atan2(mouseY,mouseX);
            //mtx2.rotate(nRadian);
            //mtx2.translate(100,100);
            //mtx2.b=Math.random()*10;
            mtx2.a=Math.random()*10;
            mtx2.b=5;
            mtx2.c=Math.random()*10;
            mtx2.d=Math.random()*10;
            myTransform.matrix=mtx2;
            
            
        }


        
        
        
        
    }
}
import flash.display.*;
import flash.filters.*;

class Particle extends MovieClip{
    
    public var clip:Sprite;
    public var color:uint;
    
    public function Particle(){
        
        color=Math.floor(Math.random()*0xffffff);
        
        graphics.lineStyle(0,0,0);
        graphics.beginFill(color);
        graphics.drawRect(0,0,100,100);
        graphics.endFill();
        
    }

    

}