Receiving an error Call to possibly undefined method getStartButton through a reference of static type class This is also happening for getQuitButton
I'm still lost on how to utilize classes as I'm new to OOP. Can someone please help me to understand what I'm doing incorrectly?
Here the function in my main class:
function getStartMenu():void {
var bFormat:TextFormat, bStart:Sprite, bQuit:Sprite;
bStart = StartMenu.getStartButton();
bQuit = StartMenu.getQuitButton();
bStart.addEventListener(MouseEvent.CLICK, bStartPress);
bQuit.addEventListener(MouseEvent.CLICK, bQuitPress);
}
in my external class file StartMenu.as
package
{
import flash.display.*;
import flash.text.TextField;
import flash.text.TextFormat;
public class StartMenu extends Sprite
{
public function StartMenu():void
{
}
public function getStartButton():Sprite {
var bFormat:TextFormat, bStart:Sprite, bStartText:TextField;
bFormat = getFormat();
bStart = getMenuButton(uint("0X00FF00"));
bStart.x = stage.stageWidth / 2 - bStart.width - 100;
bStart.y = stage.stageHeight - bStart.height - 100;
bStartText = getTextButton(bFormat, "Start");
bStartText.defaultTextFormat = bFormat;
return bStart;
}
public function getQuitButton():Sprite {
var bFormat:TextFormat, bQuit:Sprite, bQuitText:TextField
bFormat = getFormat();
bQuit = getMenuButton(uint("0X0000FF"));
bQuit.x = stage.stageWidth / 2 + 100;
bQuit.y = stage.stageHeight - bQuit.height - 100;
bQuitText = getTextButton(bFormat, "Quit");
bQuitText.defaultTextFormat = bFormat;
return bQuit;
}
public function getFormat():TextFormat {
var bFormat:TextFormat = new TextFormat()
bFormat.font = "Arial";
bFormat.bold = true;
bFormat.color = 0x000000;
bFormat.size = 28;
bFormat.align = "center";
return bFormat;
}
public function getMenuButton(bColor:uint):Sprite {
var bButton:Sprite = new Sprite();
bButton.graphics.beginFill(bColor, 1);
bButton.graphics.drawRect(0, 0, 100, 50);
bButton.graphics.endFill();
bButton.buttonMode = true;
bButton.mouseChildren = false;
return bButton
}
public function getTextButton(bFormat:TextFormat, sText:String):TextField {
var bText:TextField = new TextField()
bText.defaultTextFormat = bFormat
bText.text = sText;
bText.x = -4;
bText.y = 4;
return bText;
}
}
}