12 Replies Latest reply: Oct 30, 2011 7:25 PM by Peter Celuch RSS

    Passing arguments to a custom MC class constructor

    xTLS Community Member

      I'm having trouble with the constructor for a custom Class tied to a library MovieClip.

       

      Say I have a MovieClip in my library named Circle, which is tied to the class com.shapes.Circle . I want the Circle class contstructor to take 2 arguments, xScale and yScale:

       

      public function Circle(xScale:Number, yScale:Number) { }

       

      However, if I try to call that from in code, for example Circle ball = new Circle(3.14,2.0); , I always get an "Incorrect number of arguments. Expected 0" error.

       

      Is it possible to have a custom class tied to a MovieClip that can take arguments, or does Flash not allow this? I'd asked about this before and thought I figured it out, but from looking at it now I apparently hadn't figured it out and had resorted to a sloppy workaround; I'm hoping to fix it now.