PDA

View Full Version : Cant Remove Event Listener???



popnfresh24
August 15th, 2009, 06:14 AM
Hey... i have an "if" statement that creates an eventlistener... i then have an if statement to remove it... but everytime i have the "removeEventListener" thingy i get an error... and suggestions of why???



favourites.addEventListener(MouseEvent.CLICK, openfav);
function openfav(event:MouseEvent) {
fav.play();
inside.play();
favshadow.play();
favourites.nextFrame();
adobeilink.gotoAndStop(1);


if (adobeit.text=="full1"){
testingempty.text="finish"
adobeilink.play();
stage.addEventListener(Event.ENTER_FRAME, zee);
function zee (event:Event){

if (inside.currentFrame==50){

adobei.gotoAndStop(70);
adobei.visible=true;
adobeilink.visible=false;}

if(adobei.currentFrame==70)
{adobei.stop();}
}

}

}


favourites.addEventListener(MouseEvent.MOUSE_UP, mouseyup)
function mouseyup (event:MouseEvent) {
if (testingempty.text=="finish")
{stage.removeEventListener(Event.ENTER_FRAME, zee);}}






so when i test the movie i get this error


"1120: Access of undefined property zee."

refering to the removeEventListener function... i need to remove it because it stuffs up things down the track... and it doesn't matter where i put it or anything... it still has the problem of finding it... any help???

thanx

Gnoll
August 15th, 2009, 06:34 AM
The problem is the function zee does not exist at that point as it is nested in the function openfav, this is probably not good practice at the best of times.

Try to move the function zee outside of openfav,
Good luck,
Gnoll