ok…after my preloader i instantiate a screenHandler class which in turn instantiates a transitions class that has a public static property “exitFrames”.
When i try to check exitFrames from within the screenHandler class i get a 1119 error (access of a possibly undefined parameter …) below please find the code for the screenHandler AND the code for the transitions class. And once you find those please tell me what the bleed i’m missin’. My mom assures me that i’m smart but here we are.
the error occurs in here:
if(transTimer == transition.exitFrames){
removeOldScreen();
makeNewScreen();
transTimer = 0;
this.removeEventListener(Event.ENTER_FRAME, switchScreens);
package {
import flash.display.Sprite;
import flash.display.MovieClip;
import flash.events.Event;
public class ScreenHandler extends Sprite{
private var splashScreen:SplashScreen;
private var mainMenu:MainMenu;
private var levelSelect:LevelSelect;
private var game:Game;
private var credits:Credits;
private var victory:Victory;
private var newScreenName:String = "";
private var screenLayer:Sprite = new Sprite();
private var transitionLayer:Sprite = new Sprite();
private var transition:Transition;
private var transTimer:Number = 0;
private var makeTransition:Boolean;
public function ScreenHandler() {
this.addChild(screenLayer);
this.addChild(transitionLayer);
splashScreen = new SplashScreen();
screenLayer.addChild(splashScreen);
}
public function switchTo(screenName:String, trans:Boolean = true):void{
newScreenName = screenName;
makeTransition = trans;
this.addEventListener(Event.ENTER_FRAME, switchScreens);
}
private function switchScreens(e:Event):void{
if(makeTransition){
transTimer++;
if(transTimer == 1 && transitionLayer.numChildren < 1){
transition = new Transition1();
transitionLayer.addChild(transition);
}
if(transTimer == transition.exitFrames){
removeOldScreen();
makeNewScreen();
transTimer = 0;
this.removeEventListener(Event.ENTER_FRAME, switchScreens);
}
} else {
removeOldScreen();
makeNewScreen();
this.removeEventListener(Event.ENTER_FRAME, switchScreens);
}
}
private function removeOldScreen():void{
var oldScreen:MovieClip;
oldScreen = screenLayer.getChildAt(0) as MovieClip;
screenLayer.removeChild(oldScreen);
}
private function makeNewScreen():void{
switch(newScreenName){
case "SplashScreen":
splashScreen = new SplashScreen();
screenLayer.addChild(splashScreen);
break;
case "MainMenu":
mainMenu = new MainMenu();
screenLayer.addChild(mainMenu);
break;
case "LevelSelect":
levelSelect = new LevelSelect();
screenLayer.addChild(levelSelect);
break;
case "Game":
game = new Game();
screenLayer.addChild(game);
break;
case "Credits":
credits = new Credits();
screenLayer.addChild(credits);
break;
case "Victory":
victory = new Victory();
screenLayer.addChild(victory);
break;
default:
mainMenu = new MainMenu();
screenLayer.addChild(mainMenu);
break;
}
newScreenName = "";
}
}
}
package
{
import flash.display.MovieClip;
import flash.events.Event;
public class Transition1 extends MovieClip
{
public static var exitFrames:Number = 11;
private var timer:Number = 0;
public function ScreenTransition()
{
this.addEventListener(Event.ENTER_FRAME, remove);
this.addEventListener(Event.REMOVED_FROM_STAGE, removeListeners);
}
private function remove(e:Event):void
{
timer++;
if(timer >= 20)
{
parent.removeChild(this);
}
}
private function removeListeners(e:Event):void
{
this.removeEventListener(Event.ENTER_FRAME, remove);
this.removeEventListener(Event.REMOVED_FROM_STAGE, removeListeners);
}
}
}