flash on 2010-10-26

by enecre
♥0 | Line 33 | Modified 2010-10-26 11:29:11 | MIT License
play

ActionScript3 source code

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

package {
    import flash.text.TextField;
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
        
        private var tf:TextField = new TextField();
        private var map:Array = [];        
        
        public function FlashTest() {
            // write as3 code here..
            tf.width = tf.height = 465;
            addChild(tf);
            for(var i:int = 1; i < 10; i++){
                map = [];
                hoge(0, i);
                tr(map);
            }
        }
        
        private function hoge(sum:int, len:int):void{
            if(len == 0){
                if(map[sum] == null)map[sum] = 0;
                map[sum] += 1;
            }
            
           else{
               len--;
               for(var i:int = 1; i <= 6; i++){
                   hoge(sum + i, len);
               }
           }

        }

        
        private function tr(...o):void{
            tf.appendText(o + "\n");
            tf.scrollV = tf.maxScrollV;
        }

    }
}