Constructor with parameter : Constructor « Class « Flash / Flex / ActionScript






Constructor with parameter

 

package{
  import flash.display.Sprite;
  
  public class Main extends Sprite{
    public function Main(){

        
        var m:MultiplyNumbers = new MultiplyNumbers(2,3);

    }
  }
}

     class MultiplyNumbers {
          
          public function MultiplyNumbers(num1:Number,num2:Number):void {
               trace(num1*num2);
          }
          
     }

        








Related examples in the same category

1.Creating a Constructor
2.Add public attribute to contrustor.
3.A class named Product with a constructor and a method
4.Add assignment code to class constructor
5.Set the memeber variable in constructor
6.Declare a constructor method for the Example class