flash on 2013-7-24

by tepe
引数の挙動テスト
引数は参照を渡されている
引数に対して代入をするとオリジナルに対する代入となる
♥0 | Line 26 | Modified 2013-07-24 11:30:36 | MIT License
play

ActionScript3 source code

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

package {
    //引数の挙動テスト
    //引数は参照を渡されている
    //引数に対して代入をするとオリジナルに対する代入となる
    import flash.display.Sprite;
    import flash.events.*;
    public class FlashTest extends Sprite {
        public function FlashTest() {
            // write as3 code here..
            var s:Sprite = new Sprite();
            addChild(s);
            func(s);
        }
        
        private function func(s2:Sprite,col:uint=0xff0000):void{
            var s:Sprite = new Sprite()
            s2 = s;
            s.graphics.clear();
            s.graphics.beginFill(0xff0000);
            s.graphics.drawRect(0,0,30,30);
            s.graphics.endFill();
            s.x = 100;
            s.y = 100;
            s.addEventListener(MouseEvent.CLICK,onClick);
            addChild(s);
        }
        private function onClick(e:MouseEvent):void{
            e.target.graphics.clear();
        }


    }
}