0

Using Flash Professional CS5, I'm trying to add a child object in my script. I want to give the class which creates the child-object as parameter while creating. The problem is when I try to test the project, I get an error stating Incorrect number of arguments. 0 expected.

My MainClass.as:

package  {

import flash.display.MovieClip;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.ui.Keyboard;

public class MainClass extends MovieClip {

    var menuClass:MenuClass;
    var gameClass:GameClass;
    var highClass:HighscoreClass;

    public function Main() {
        this.StartOfProject();
    }

    public function StartOfProject() {
        menuClass = new MenuClass(this);
        this.addChild(menuClass);
        highClass = new HighscoreClass();
    }

And my MenuClass.as:

package  {

public class MenuClass extends MovieClip {
    var mainClass:MainClass;

    public function Menu(mainClass:MainClass) {
        this.mainClass = mainClass;
        ...
    }

What am I doing wrong?

Joetjah
  • 6,292
  • 8
  • 55
  • 90

2 Answers2

1

You named the constructor of your MenuClass incorrectly. It should be "MenuClass" not "Menu"

bwroga
  • 5,379
  • 2
  • 23
  • 25
1

change:

public function Main() { this.StartOfProject(); }

to:

public function MainClass() { this.StartOfProject(); }

and: public function Menu(mainClass:MainClass)

to: public function MenuClass (mainClass:MainClass)

and see if this already solves your problem