I am creating a game in ActionScript. I am running into problems with object oriented programming in actionscript. I have a game_fla which hosts the library components of the game. The one which is causing problems is a splash movie clip. Within this movie clip I have a few layers that animate and load a logo and two buttons. In the document class game.as, I have the following code:
package{
import flash.display.MovieClip;
public class the_game extends MovieClip {
public var splash_screen:splash;
public var play_screen:the_game_itself;
public var how_to_play_screen:how_to_play;
public function the_game() {
show_splash();
}
public function show_splash() {
splash_screen = new splash(this);
addChild(splash_screen);
}
public function play_the_game() {
play_screen = new the_game_itself(this,level);
remove_splash();
addChild(play_screen);
}
etc..
This obviously refers to a splash.as file which holds the information regarding the splash components. This is the code for splash.as:
package {
import flash.display.MovieClip;
import flash.display.SimpleButton;
import flash.events.MouseEvent;
public class splash extends MovieClip {
public var main_class:the_game;
public function splash(passed_class:the_game) {
main_class = passed_class;
play_btn.addEventListener(MouseEvent.CLICK, playGame);
howToPlay_btn.addEventListener(MouseEvent.CLICK, howToPlay);
}
public function playGame(event:MouseEvent):void{
main_class.play_the_game();
}
public function howToPlay(event:MouseEvent):void{
main_class.how_to_play();
}
}
}
To my point! The problem I am having is that when I run the game.fla file, I am getting a compiler error for the splash.as file saying "1120:Access of undefined property play_btn and howToPlay_btn". These buttons like I mentioned are within the movie clip splash_mc. (all have instance names etc..) Just not sure where I am going wrong? By the way, I originally had the as files using Sprite as opposed to Movie Clip but neither work anyways.
HELP? Please? Anyone?