I use two classes for my current project, a document class and a menuscreen class. I have a function in my document class called startGame that i want to run from the menuscreen class when a button is clicked. I’m nearly there but i’m getting an error when i try to run it:
1136: Incorrect number of arguments. Expected 1.
The error is at line 17 in the menuscreen class, the line that tries to run the function from the document class. I don’t understand what kind of argument it wants. Also, i’m not sure if the startGame function should be (event:Event) Hope someone can enlighten me on what’s wrong! Cheers!
DocumentClass
package
{
import flash.display.MovieClip;
import flash.events.Event;
public class DocumentClass extends MovieClip
{
public var menuScreen:MenuScreen;
public function DocumentClass()
{
menuScreen = new MenuScreen();
menuScreen.x = 0;
menuScreen.y = 0;
addChild( menuScreen );
}
public function startGame(event:Event)
{
// add play screen
menuScreen = null;
}
}
}
MenuScreen class
package
{
import flash.display.MovieClip;
import flash.events.MouseEvent;
public class MenuScreen extends MovieClip
{
public var documentClass:DocumentClass;
public function MenuScreen()
{
documentClass = new DocumentClass ;
startButton.addEventListener( MouseEvent.CLICK, onClick );
}
public function onClick(event:MouseEvent):void
{
documentClass.startGame()
}
}
}