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

Mathサンプル

Get Adobe Flash player
by tak_maeda 12 Jun 2009
    Embed
/**
 * Copyright tak_maeda ( http://wonderfl.net/user/tak_maeda )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/uRiD
 */

package {
    import flash.display.Sprite;
    import flash.events.Event;
    
    
    

    public class FlashTest extends Sprite {
       
        private const 総数:uint=12;
        private const 半径:uint=200;
        private var 角度:uint=0
        private var ボールを入れる配列:Array=[];
        private var いれもの:Sprite
        
      
        
        public function FlashTest() {
          
          addEventListener(Event.ADDED_TO_STAGE,はじまり);
        }
        
        private function はじまり(e:Event):void
        {
           removeEventListener(Event.ADDED_TO_STAGE,はじまり);
           いれもの=new Sprite()
          
           addChild(いれもの)
           
           ボールをつくる()
        }
        
        private function ボールをつくる():void
        {
            for(var 何番目:uint=0;何番目<総数;何番目++){
                ボールを入れる配列.push(いれもの.addChild(new ボール(何番目,総数)))
            }
            描画を設定()
        }
        
        private function 描画を設定():void
        {
         
             addEventListener(Event.ENTER_FRAME,描画する)   
        }
        
        private function 描画する(e:Event):void
        {
            角度=角度+((mouseX-stage.stageWidth/2)/stage.stageWidth/2)*30
            for(var 何番目:uint=0;何番目<総数;何番目++){
                
        var コサイン:Number=Math.cos((ボールを入れる配列[何番目]["角度"]+角度)*Math.PI/180)
                var サイン:Number=Math.sin((ボールを入れる配列[何番目]["角度"]+角度)*Math.PI/180)
                ボールを入れる配列[何番目]["x"]=コサイン*半径+stage.stageWidth/2
                ボールを入れる配列[何番目]["y"]=stage.stageHeight/2
                ボールを入れる配列[何番目]["scaleX"]=(1-サイン)/2+0.5
                ボールを入れる配列[何番目]["scaleY"]=(1-サイン)/2+0.5
                ボールを入れる配列[何番目].alpha=(1-サイン)+0.5
               if(サイン<-0.9){
                   いれもの.setChildIndex(ボールを入れる配列[何番目],総数-1)
               }else if(サイン>0.9){
                   いれもの.setChildIndex(ボールを入れる配列[何番目],0)
               }
            }
            
        }
    }
    
    
}


import flash.display.Sprite;
import flash.display.Graphics
class ボール extends Sprite
{
     private var gra:Graphics
     private var 番号:uint;
     public var 角度:Number;
     public function ボール(何番目:uint,総数:uint)
     {
         番号=何番目;
         gra=graphics;
         まるをかく();
         角度=360/総数*番号
         
     }
     
     private function まるをかく():void
     {
         gra.beginFill(0xFFFFFF*Math.random())
         gra.drawCircle(0,0,20)   
     }   
}