removeEventListener

I have this class that I am using for a menu and when I want to kill the ENTER_FRAME event from main I access it using

planeName.newMenu.killMouseMove();

where planeName is the name of the “page” i am in, newMenu is the name of the menu class instance and killMouseMove() is the name of the public function I wrote to kill the ENTER_FRAME listener. Here is the code for the menu class


package com.xillo.ui
{
    
    import flash.events.*;
    import flash.display.MovieClip;
    import flash.geom.ColorTransform;
    import flash.display.Sprite;
    import IntMenuRed_mc;
    import IntMenuRedInv_mc;
    import IntMenuGreen_mc;
    import IntMenuGreenInv_mc;
    import IntMenuBlue_mc;
    import IntMenuBlueInv_mc;
    import IntMenuBlack_mc;
    import IntMenuBlackInv_mc;
    import IntMenuPur_mc;
    import IntMenuPurInv_mc;
    import BraMenuRed_mc;
    import BraMenuRedInv_mc;
    import BraMenuGreen_mc;
    import BraMenuGreenInv_mc;
    import BraMenuBlue_mc;
    import BraMenuBlueInv_mc;
    import BraMenuBlack_mc;
    import BraMenuBlackInv_mc;
    import BraMenuPur_mc;
    import BraMenuPurInv_mc;
    import BroMenuRed_mc;
    import BroMenuRedInv_mc;
    import BroMenuGreen_mc;
    import BroMenuGreenInv_mc;
    import BroMenuBlue_mc;
    import BroMenuBlueInv_mc;
    import BroMenuBlack_mc;
    import BroMenuBlackInv_mc;
    import BroMenuPur_mc;
    import BroMenuPurInv_mc;
    import CliMenuRed_mc;
    import CliMenuRedInv_mc;
    import CliMenuGreen_mc;
    import CliMenuGreenInv_mc;
    import CliMenuBlue_mc;
    import CliMenuBlueInv_mc;
    import CliMenuBlack_mc;
    import CliMenuBlackInv_mc;
    import CliMenuPur_mc;
    import CliMenuPurInv_mc;
    import TecMenuRed_mc;
    import TecMenuRedInv_mc;
    import TecMenuGreen_mc;
    import TecMenuGreenInv_mc;
    import TecMenuBlue_mc;
    import TecMenuBlueInv_mc;
    import TecMenuBlack_mc;
    import TecMenuBlackInv_mc;
    import TecMenuPur_mc;
    import TecMenuPurInv_mc;
    import ProMenuRed_mc;
    import ProMenuRedInv_mc;
    import ProMenuGreen_mc;
    import ProMenuGreenInv_mc;
    import ProMenuBlue_mc;
    import ProMenuBlueInv_mc;
    import ProMenuBlack_mc;
    import ProMenuBlackInv_mc;
    import ProMenuPur_mc;
    import ProMenuPurInv_mc;
    import MotMenuRed_mc;
    import MotMenuRedInv_mc;
    import MotMenuGreen_mc;
    import MotMenuGreenInv_mc;
    import MotMenuBlue_mc;
    import MotMenuBlueInv_mc;
    import MotMenuBlack_mc;
    import MotMenuBlackInv_mc;
    import MotMenuPur_mc;
    import MotMenuPurInv_mc;
    import com.xillo.ui.SoundPlayer;
    
    import caurina.transitions.Tweener;
    
    public class NewMenu2MC extends MovieClip
    {
        
        
        private var _currColor:String;
        private var _currPlane:String;
        public var _currMenu:MovieClip;
        private var chiral:String;
        public var menuR:MovieClip;
        public var menuRI:MovieClip;
        public var menuG:MovieClip;
        public var menuGI:MovieClip;
        public var menuB:MovieClip;
        public var menuBI:MovieClip;
        public var menuBl:MovieClip;
        public var menuBlI:MovieClip;
        public var menuP:MovieClip;
        public var menuPI:MovieClip;
        private var startWidth:Number;
        private var startHeight:Number;
        private var _color1:Number;
        private var _color2:Number;
        private var _frameNo:Number;
        private var c4_test:SoundPlayer;
        private var b3_test:SoundPlayer;
        private var a3_test:SoundPlayer;
        private var g3_test:SoundPlayer;
        private var f3_test:SoundPlayer;
        private var e3_test:SoundPlayer;
        private var d3_test:SoundPlayer;
        private var c3_test:SoundPlayer;
        private var noteState:String = "";
        
        public function NewMenu2MC(currColor:String = "red", currPlane:String = "interactive")
        {
            _currColor = currColor;
            _currPlane = currPlane;
            _currMenu = new MovieClip();
            buildMenu();
            changeColor(currColor);
            addMouseMove();
            trace("in NewMenu2MC");
            loadSounds();
        }
        public function addMouseMove():void {
            addEventListener(Event.ENTER_FRAME,menuAction);
            trace("adding Mouses move for: "+this)
            //removes mouseevent for title node
            
            
        }
        public function killMouseMove():void {
            trace("killing Mouses move for: "+this)
            removeEventListener(Event.ENTER_FRAME,menuAction);
            
            //removes mouseevent for title node
            
            
        }
        
        public function changeColor(currColor):void {
            this.menuR.visible = false;
            this.menuRI.visible = false;
            this.menuG.visible = false;
            this.menuGI.visible = false;
            this.menuB.visible = false;
            this.menuBI.visible = false;
            this.menuBl.visible = false;
            this.menuBlI.visible = false;
            this.menuP.visible = false;
            this.menuPI.visible = false;
            
            switch(currColor) {
                case "red":
                    _currMenu = menuR;
                    break;
                    
                case "red_inv":
                    _currMenu = menuRI;
                    break;
                    
                case "green":
                    _currMenu = menuG;
                    break;
                    
                case "green_inv":
                    _currMenu = menuGI;
                    break;
                    
                case "blue":
                    _currMenu = menuB;
                    break;
                    
                case "blue_inv":
                    _currMenu = menuBI;
                    break;
                    
                case "black":
                    _currMenu = menuBl;
                    break;
                    
                case "black_inv":
                    _currMenu = menuBlI;
                    break;
                    
                case "purple":
                    _currMenu = menuP;
                    break;
                    
                case "purple_inv":
                    _currMenu = menuPI;
                    break;
                    
                default:
                    _currMenu = menuR;
                    
            }
            _currMenu.visible = true;
            trace("in ChangeColor: "+currColor);
            
        }
        
        private function buildMenu():void {
            //trace("in buildMenu for "+_currPlane)
            switch(_currPlane) {
                case "interactive":
                    //trace(_currPlane);
                    menuR = new IntMenuRed_mc();
                    menuRI = new IntMenuRedInv_mc();
                    menuG = new IntMenuGreen_mc();
                    menuGI = new IntMenuGreenInv_mc();
                    menuB = new IntMenuBlue_mc();
                    menuBI = new IntMenuBlueInv_mc();
                    menuBl = new IntMenuBlack_mc();
                    menuBlI = new IntMenuBlackInv_mc();
                    menuP = new IntMenuPur_mc();
                    menuPI = new IntMenuPurInv_mc();
                    break;
                    
                case "branding":
                    //trace(_currPlane);
                    menuR = new BraMenuRed_mc();
                    menuRI = new BraMenuRedInv_mc();
                    menuG = new BraMenuGreen_mc();
                    menuGI = new BraMenuGreenInv_mc();
                    menuB = new BraMenuBlue_mc();
                    menuBI = new BraMenuBlueInv_mc();
                    menuBl = new BraMenuBlack_mc();
                    menuBlI = new BraMenuBlackInv_mc();
                    menuP = new BraMenuPur_mc();
                    menuPI = new BraMenuPurInv_mc();
                    break;
                    
                case "clientele":
                    //trace(_currPlane);
                    menuR = new CliMenuRed_mc();
                    menuRI = new CliMenuRedInv_mc();
                    menuG = new CliMenuGreen_mc();
                    menuGI = new CliMenuGreenInv_mc();
                    menuB = new CliMenuBlue_mc();
                    menuBI = new CliMenuBlueInv_mc();
                    menuBl = new CliMenuBlack_mc();
                    menuBlI = new CliMenuBlackInv_mc();
                    menuP = new CliMenuPur_mc();
                    menuPI = new CliMenuPurInv_mc();
                    break;
                    
                case "motion":
                    
                    //trace(_currPlane);
                    menuR = new MotMenuRed_mc();
                    menuRI = new MotMenuRedInv_mc();
                    menuG = new MotMenuGreen_mc();
                    menuGI = new MotMenuGreenInv_mc();
                    menuB = new MotMenuBlue_mc();
                    menuBI = new MotMenuBlueInv_mc();
                    menuBl = new MotMenuBlack_mc();
                    menuBlI = new MotMenuBlackInv_mc();
                    menuP = new MotMenuPur_mc();
                    menuPI = new MotMenuPurInv_mc();
                    break;
                    
                case "broadcast":
                    //trace(_currPlane);
                    menuR = new BroMenuRed_mc();
                    menuRI = new BroMenuRedInv_mc();
                    menuG = new BroMenuGreen_mc();
                    menuGI = new BroMenuGreenInv_mc();
                    menuB = new BroMenuBlue_mc();
                    menuBI = new BroMenuBlueInv_mc();
                    menuBl = new BroMenuBlack_mc();
                    menuBlI = new BroMenuBlackInv_mc();
                    menuP = new BroMenuPur_mc();
                    menuPI = new BroMenuPurInv_mc();
                    break;
                    
                case "technology":
                    //trace(_currPlane);
                    menuR = new TecMenuRed_mc();
                    menuRI = new TecMenuRedInv_mc();
                    menuG = new TecMenuGreen_mc();
                    menuGI = new TecMenuGreenInv_mc();
                    menuB = new TecMenuBlue_mc();
                    menuBI = new TecMenuBlueInv_mc();
                    menuBl = new TecMenuBlack_mc();
                    menuBlI = new TecMenuBlackInv_mc();
                    menuP = new TecMenuPur_mc();
                    menuPI = new TecMenuPurInv_mc();
                    break;
                    
                case "propaganda":
                    //trace(_currPlane);
                    menuR = new ProMenuRed_mc();
                    //trace("finished building ProMenuRed_mc");
                    menuRI = new ProMenuRedInv_mc();
                    //trace("finished building ProMenuRedInv_mc");
                    menuG = new ProMenuGreen_mc();
                    //trace("finished building ProMenuGreen_mc");
                    menuGI = new ProMenuGreenInv_mc();
                    //trace("finished building ProMenuGreenInv_mc");
                    menuB = new ProMenuBlue_mc();
                    //trace("finished building ProMenuBlue_mc");
                    menuBI = new ProMenuBlueInv_mc();
                    //trace("finished building ProMenuBlueInv_mc");
                    menuBl = new ProMenuBlack_mc();
                    //trace("finished building ProMenuBlack_mc");
                    menuBlI = new ProMenuBlackInv_mc();
                    //trace("finished building ProMenuBlackInv_mc");
                    menuP = new ProMenuPur_mc();
                    //trace("finished building ProMenuPur_mc");
                    menuPI = new ProMenuPurInv_mc();
                    //trace("finished building ProMenuPurInv_mc");
                    //trace("finished building "+_currPlane);
                    break;
                    
                default:
                    //trace(_currPlane);
                    menuR = new IntMenuRed_mc();
                    menuRI = new IntMenuRedInv_mc();
                    menuG = new IntMenuGreen_mc();
                    menuGI = new IntMenuGreenInv_mc();
                    menuB = new IntMenuBlue_mc();
                    menuBI = new IntMenuBlueInv_mc();
                    menuBl = new IntMenuBlack_mc();
                    menuBlI = new IntMenuBlackInv_mc();
                    menuP = new IntMenuPur_mc();
                    menuPI = new IntMenuPurInv_mc();
                    trace "no plane";
            
            }
            //color instances
            
            this.addChild(menuR);
            this.addChild(menuRI);
            this.addChild(menuG);
            this.addChild(menuGI);
            this.addChild(menuB);
            this.addChild(menuBI);
            this.addChild(menuBl);
            this.addChild(menuBlI);
            this.addChild(menuP);
            this.addChild(menuPI);
            
        }
        
        
        private function menuAction(e:Event):void {
            //check to see if mouse is within the boundaries of the menu
            trace("in menuAction e: "+e +" ");
            
            switch(_currPlane){
                
                case "interactive":
                    //trace("this.mouseY = "+this.mouseY);
                    _frameNo = Math.round(((this.mouseY-37.5)/(this.height-75))*114 )+2;
                    if(this.mouseY > 37.5 && this.mouseY < 160 && this.mouseX > -200 && this.mouseX < 0 ) {
                        //trace("in interactive _frameNo = "+_frameNo);
                        if(_frameNo> 114){
                            _frameNo = 115;
                        }
                        this._currMenu.gotoAndStop(_frameNo);
                        trace("_frameNo = "+_frameNo);
                        playScale(_frameNo);
                    } else if(this.mouseY > 3 && this.mouseY < 37.5 && this.mouseX > -200 && this.mouseX < 0 ){
                        //playScale(8);
                    } else {
                        //trace("Mouse out");
                        noteState = "";
                        this._currMenu.gotoAndStop(1);
                        killMouseMove();
                    }
            
                break;
                
                case "clientele":
                    //trace("this.mouseY = "+this.mouseY);
                    _frameNo = Math.round(((this.mouseY-37.5)/(this.height-75))*114 )+2;
                    if(this.mouseY > 37.5 && this.mouseY < 160 && this.mouseX > -200 && this.mouseX < 0 ) {
                        //trace("frameNo = "+_frameNo);
                        if(_frameNo> 114){
                            _frameNo = 115;
                        }
                        this._currMenu.gotoAndStop(_frameNo);
                        playScale(_frameNo);
                    } else {
                        /*//trace("Mouse out");*/
                        noteState = "";
                        _currMenu.gotoAndStop(1);
                    }
            
                break;
                
                case "branding":
                    //trace("this.mouseY = "+this.mouseY);
                    _frameNo = Math.abs(114-Math.round(((this.mouseY-37.5)/(this.height-75))*114 ))+2;
                    if(this.mouseY > 0 && this.mouseY < 123 && this.mouseX > -180 && this.mouseX < 0 ) {
                        //trace("frameNo = "+frameNo);
                        if(_frameNo> 114){
                            _frameNo = 115;
                        }
                        _currMenu.gotoAndStop(_frameNo);
                        playScale(_frameNo);
                        
                    } else {
                        /*//trace("Mouse out");*/
                        noteState = "";
                        _currMenu.gotoAndStop(1);
                    }
            
                break;
                
                case "propaganda":
                    //trace("this.mouseY = "+this.mouseY);
                    _frameNo = Math.abs(114-Math.round(((this.mouseY-37.5)/(this.height-75))*114 ))+2;
                    if(this.mouseY > 0 && this.mouseY < 140 && this.mouseX > -180 && this.mouseX < 0 ) {
                        //trace("frameNo = "+frameNo);
                        if(_frameNo> 114){
                            _frameNo = 115;
                        }
                        /*//trace("_frameNo = "+_frameNo);
                        ////trace("this.mouseY = "+this.mouseY);*/
                        _currMenu.gotoAndStop(_frameNo);
                        playScale(_frameNo);
                        
                    } else {
                        /*//trace("Mouse out");*/
                        noteState = "";
                        _currMenu.gotoAndStop(1);
                        //playScale(8);
                    }
            
                break;
                
                case "motion":
                    //trace("this.mouseY = "+this.mouseY);
                    _frameNo = Math.round(((this.mouseY-37.5)/(this.height-75))*114 )+2;
                    if(this.mouseY > 37.5 && this.mouseY < 163 && this.mouseX < 180 && this.mouseX > 0 ) {
                        //trace("_frameNo = "+_frameNo);
                        if(_frameNo> 114){
                            _frameNo = 115;
                        }
                        /*//trace("_frameNo = "+_frameNo);
                        ////trace("this.mouseY = "+this.mouseY);*/
                        playScale(_frameNo);
                        _currMenu.gotoAndStop(_frameNo);
                    } else {
                        /*//trace("Mouse out");*/
                        noteState = "";
                        _currMenu.gotoAndStop(1);
                    }
                    break;
                
                case "broadcast":
                    //trace("this.mouseY = "+this.mouseY);
                    _frameNo = Math.abs(114-Math.round(((this.mouseY-37.5)/(this.height-75))*114 ))+2;
                    if(this.mouseY > 0 && this.mouseY < 140 && this.mouseX < 180 && this.mouseX > 0 ) {
                        //trace("_frameNo = "+_frameNo);
                        //trace("this.mouseY = "+this.mouseY + "this.mouseX = "+this.mouseX);
                        if(_frameNo> 114){
                            _frameNo = 115;
                        }
                        _currMenu.gotoAndStop(_frameNo);
                        playScale(_frameNo);
                    } else {
                        /*//trace("Mouse out");*/
                        noteState = "";
                        _currMenu.gotoAndStop(1);
                    }
                    break;
                
                case "technology":
                    //trace("this.mouseY = "+this.mouseY);
                    _frameNo = Math.abs(114-Math.round(((this.mouseY-37.5)/(this.height-75))*114 ))+2;
                    if(this.mouseY > 0 && this.mouseY < 140 && this.mouseX < 180 && this.mouseX > 0 ) {
                        //trace("_frameNo = "+_frameNo);
                        if(_frameNo> 114){
                            _frameNo = 115;
                        }
                        _currMenu.gotoAndStop(_frameNo);
                        playScale(_frameNo);
                    } else {
                        /*//trace("Mouse out");*/
                        
                        _currMenu.gotoAndStop(1);
                        noteState = "";
                    }
                    break;
                    
                default:
                    //trace("no plane");
                    
            }
            
        }
        private function loadSounds():void {
            trace("loading sounds");
            c4_test = new SoundPlayer("c4_test");
            b3_test = new SoundPlayer("b3_test");
            a3_test = new SoundPlayer("a3_test");
            g3_test = new SoundPlayer("g3_test");
            f3_test = new SoundPlayer("f3_test");
            e3_test = new SoundPlayer("e3_test");
            d3_test = new SoundPlayer("d3_test");
            c3_test    = new SoundPlayer("c3_test");
                    
                    
        }
        private function playScale(frameNo):void {
            if(_currPlane == "interactive" || _currPlane == "motion" || _currPlane == "interactive") {
                if (frameNo > 3 && frameNo < 16 && noteState != "1st" ) {
                    c4_test.playSound();
                    noteState = "1st";
                    trace("_frameNo = "+_frameNo);
                } else if (frameNo > 16 && frameNo < 32 && noteState != "2nd" ) {
                    b3_test.playSound();
                    noteState = "2nd";
                    trace("_frameNo = "+_frameNo);
                } else if (frameNo > 32 && frameNo < 48 && noteState != "3rd" ) {
                    a3_test.playSound();
                    noteState = "3rd";
                    trace("_frameNo = "+_frameNo);
                } else if (frameNo > 48 && frameNo < 64 && noteState != "4rth" ) {
                    g3_test.playSound();
                    noteState = "4rth";
                    trace("_frameNo = "+_frameNo);
                } else if (frameNo > 64 && frameNo < 80 && noteState != "5th" ) {
                    f3_test.playSound();
                    noteState = "5th";
                    trace("_frameNo = "+_frameNo);
                } else if (frameNo > 80 && frameNo < 96 && noteState != "6th" ) {
                    e3_test.playSound();
                    noteState = "6th";
                    trace("_frameNo = "+_frameNo);
                } else if (frameNo > 96 && frameNo < 116 && noteState != "7th" ) {
                    d3_test.playSound();
                    noteState = "7th";
                    trace("_frameNo = "+_frameNo);
                } else  {
                    trace("no note: "+frameNo)
                } 
            } else {
                if (frameNo > 3 && frameNo < 16 && noteState != "1st" ) {
                    b3_test.playSound();
                    noteState = "1st";
                } else if (frameNo > 18 && frameNo < 30 && noteState != "2nd" ) {
                    a3_test.playSound();
                    noteState = "2nd";
                } else if (frameNo > 32 && frameNo < 48 && noteState != "3rd" ) {
                    g3_test.playSound();
                    noteState = "3rd";
                } else if (frameNo > 48 && frameNo < 64 && noteState != "4rth" ) {
                    f3_test.playSound();
                    noteState = "4rth";
                } else if (frameNo > 64 && frameNo < 80 && noteState != "5th" ) {
                    e3_test.playSound();
                    noteState = "5th";
                } else if (frameNo > 80 && frameNo < 96 && noteState != "6th" ) {
                    d3_test.playSound();
                    noteState = "6th";
                } else if (frameNo > 96 && frameNo < 116 && noteState != "7th" ) {
                    c3_test.playSound();
                    noteState = "7th";
                } else  {
                    trace("no note: "+frameNo)
                } 

                
            }
            
        }
           
        
        
        
    }
}


there is a lot of stuff going on here most of which works the question I have is with the killMouseMove(); function. As a test I called the killMouseMove(); from the menuAction() action function in the “interactive” case when the mouseY got out of a certain range and it works, kills the ENTER_FRAME action no problem. But when I call it from my constructor with

planeName.newMenu.killMouseMove();

I get the trace statement in the function but it does not actually kill the ENTER_FRAME listener. Any ideas on why this is? I tried using this. in front of both the addEvent and removeEvent but that seemed to make no difference. Thanks for your help and sorry for the amount of code to wade through.

V