Create a method and then call it by name : Method « Class « Flash / Flex / ActionScript






Create a method and then call it by name

 

package {
    import flash.display.Sprite;

    public class Main extends Sprite
    {
        public function Main(  ) {
            for(var i:int=0;i<10;i++) {
                drawLine(  );
            }
        }
    
        private function drawLine(  ):void {
            graphics.lineStyle(1, Math.random(  ) * 0xffffff, 1);
            graphics.moveTo(Math.random(  ) * 400, Math.random(  ) * 400);
            graphics.lineTo(Math.random(  ) * 400, Math.random(  ) * 400);
        }
    }
}

        








Related examples in the same category

1.Defining Methods for a Class
2.Adding Static Methods to a Class
3.A simple example of a method declaration using parameters
4.Change member variable value in member method