InLiquidWonder
April 10th, 2009, 07:10 PM
Hey folks,
I keep getting weird errors for this series of functions. Essentially, I have a tutorial section of a game where I want to display movieclips in succession (instruction screens), so I have one movieclip being instantiated, then triggering the next and removing itself when it gets clicked on. Currently, the code launches all three instruction windows at once, and then throws an error and creates more screens when you click on it.
This is part of the main game controlling class, called JenGrierThesisHunter, hence the occasional self-referencing I did in the code to get it to break less. I don't know if this is correct, though, but it's the closest I've gotten to working it out.
public function onIntro(event:MouseEvent)
{
introButton.removeEventListener(MouseEvent.CLICK, onIntro);
var intro1:IntroMessage1 = new IntroMessage1();
intro1.y = 25;
intro1.x = 50;
addChild(intro1);
addEventListener(MouseEvent.CLICK, message1Handler);
}
public function message1Handler(event:MouseEvent)
{
var intro2:IntroMessage2 = new IntroMessage2();
intro2.y = 25;
intro2.x = 50;
addChild(intro2);
removeEventListener(MouseEvent.CLICK, message2Handler);
removeChild(JenGrierThesisHunter.main.intro1);
}
public function message2Handler(event:MouseEvent)
{
var intro3:IntroMessage3 = new IntroMessage3();
intro3.y = 25;
intro3.x = 50;
addChild(intro3);
removeEventListener(MouseEvent.CLICK, message2Handler);
removeChild(JenGrierThesisHunter.main.intro2);
}
public function message3Handler(event:MouseEvent)
{
removeEventListener(MouseEvent.CLICK, message3Handler);
removeChild(JenGrierThesisHunter.main.intro3);
}
The error that comes up with is "ReferenceError: Error #1069: Property intro1 not found on JenGrierThesisHunter and there is no default value.
at JenGrierThesisHunter/message1Handler()"
Any suggestions/advice appreciated! Thanks!
I keep getting weird errors for this series of functions. Essentially, I have a tutorial section of a game where I want to display movieclips in succession (instruction screens), so I have one movieclip being instantiated, then triggering the next and removing itself when it gets clicked on. Currently, the code launches all three instruction windows at once, and then throws an error and creates more screens when you click on it.
This is part of the main game controlling class, called JenGrierThesisHunter, hence the occasional self-referencing I did in the code to get it to break less. I don't know if this is correct, though, but it's the closest I've gotten to working it out.
public function onIntro(event:MouseEvent)
{
introButton.removeEventListener(MouseEvent.CLICK, onIntro);
var intro1:IntroMessage1 = new IntroMessage1();
intro1.y = 25;
intro1.x = 50;
addChild(intro1);
addEventListener(MouseEvent.CLICK, message1Handler);
}
public function message1Handler(event:MouseEvent)
{
var intro2:IntroMessage2 = new IntroMessage2();
intro2.y = 25;
intro2.x = 50;
addChild(intro2);
removeEventListener(MouseEvent.CLICK, message2Handler);
removeChild(JenGrierThesisHunter.main.intro1);
}
public function message2Handler(event:MouseEvent)
{
var intro3:IntroMessage3 = new IntroMessage3();
intro3.y = 25;
intro3.x = 50;
addChild(intro3);
removeEventListener(MouseEvent.CLICK, message2Handler);
removeChild(JenGrierThesisHunter.main.intro2);
}
public function message3Handler(event:MouseEvent)
{
removeEventListener(MouseEvent.CLICK, message3Handler);
removeChild(JenGrierThesisHunter.main.intro3);
}
The error that comes up with is "ReferenceError: Error #1069: Property intro1 not found on JenGrierThesisHunter and there is no default value.
at JenGrierThesisHunter/message1Handler()"
Any suggestions/advice appreciated! Thanks!