i am new to as3. i have a game that i want to put load screen on, which i created a separate class for. first the main class is initialized and in the constructor function, it does an addChild(loadScreen) which places an instance of the loadScreen MC on the stage. within the loadScreen is a “Play Button” that when a user presses this button i want it to continue startGame in the Main class. the way i tried it was Main.startGame from the loadScreen class, but that obviously does not work. is it possible to call a function from a different class, or is there just a simpler way of doing this that i am missing?
i have three files:
Main.fla
Main.as
loadScreen.as
the Main.as file:
package
{
import flash.text.*;
import flash.display.*;
import flash.events.*;
public class Main extends Sprite
{
var startPage:loadScreen = new loadScreen();
public function Main()
{
addChild(startPage);
}
public function startGame()
{
// The meat of the code for the game is here
}
}
}
the loadScreen.as file:
package {
import flash.text.*;
import flash.display.*;
import flash.events.*;
public class loadScreen extends MovieClip {
public function loadScreen() {
bLoad.buttonMode=true;
bLoad.addEventListener(MouseEvent.CLICK,playGame);
}
public function playGame(e:MouseEvent) {
Memory.startGame(); // <----- SOMETHING THAT DOES THIS
}
}
}