Skip to main content
Inspiring
February 14, 2013
Question

Error 1136: expects 0 arguments but constructor needs 2

Hi. In my project I have a Box class that extends MovieClip, and Box has instances of the Egg class. The Egg class receives two arguments on instantiation, month (a string) and size (an int).

Here's my code:

package com.stuff {

import flash.display.MovieClip;

import com.stuff.Egg;

public class Box extends MovieClip {

     private var Egg1:Egg = new Egg("jan", 2);

     private var Egg2:Egg = new Egg("feb", 5);

     public function Box():void {

     }

}

}

package com.stuff {

public class Egg {

     public function Egg(m:String, s:int):void {

     }

}

}

When I test the movie I get the following error: 1136: Incorrect number of arguments. Expected 0.

What am I doing wrong? Thank you.

This topic is closed to new replies. Start a new post to keep the conversation going.

7 replies

Nabren
Inspiring
February 14, 2013

I doubt this is your issue but I never have return types on the constructor - depending on the version of the Flex SDK that you are using and program version maybe it does matter though? Maybe by adding the return type it is hiding that as the constructor.

Translate
Amy Blankenship
Legend
February 14, 2013

The arguments look fine, but a constructor should not have any return value, even void. It's possible the compiler is giving you the wrong error with this situation. Note that if you use Flash Builder to create your Classes, you can create the constructor by checking a box. And you can add a constructor later (in FB) by typing constr Ctrl-Space-Enter.

Translate
Inspiring
February 14, 2013

Thank you so much, Amy. I tried removing the :void in both constructors, but the error remains. I'm using Flash CS6 on Mac OSX, by the way, in case this changes anything.

The code I'm using is a simplified example of my project, I didn't post the actual code because both classes are a bit big to post here and my code is in portuguese...

Translate
Amy Blankenship
Legend
February 14, 2013

Try using the actual code you posted (without the void). I suspect you won't see any errors. Work backward from there.

Translate