Reprogram navigation from procedural to OOP #2

Hello,

Have little unusual navigations made in Flash. Animations are made by timeline and all elements are on stage (exept the movieclips-buttons). I loaded buttons manually with class, than I made actions for specific button.

BtnL is (parent) container of next buttons: BtnL1, BtnL2, BtnL3, BtnL4. And similarly BtnR in (parent) container of buttons: BtnR1, BtnR2, BtnR3, BtnR4. When click on any of Left button, he cause timeline (animation) to play(); and the same time this clicked button cause his right neighbor button to “down state”. The same is for any child of BtnR, they cause animation to go backward (backward states are at timeline from frame 80 further), like for example; gotoAndPlay(83); and ENTER_FRAME in main class than at frame (case) 90 cause gotoAndStop(71);, because the “interactive” keyframes are at: 1, 11, 21, 31, 41, 51, 61 and 71. Thats because for each click on any button, all buttons change the functionality (apparently); Explanation: if clicked at any left side button, he(BtnL3) obtain “purpose” of his right neighbor button (BtnL4) and his(BtnL3) “purpose” transfers to his neighbor button (BtnL2), and his neighbor button’s to his neighbor(BtnL1) and btnL1 to BtnR1. If clicked at right side button is the same, but move throuth that side, so BtnR3 transfers purpose to BtnR2, BtnR2 transfers to BtnR1 and BtnR1 to BtnL1.

First I programmed it proceduraly (layer acitons), and it WORKED… But the problem is now that shoul be in OOP (programed with classes), because I need to import it to Flex and procedural version of course there don’t work.

Please help Someone, I’m getting depresed of this OOP. I could post working (procedural) version, to betten understanding.

First error: BtnLmc.as, Line 13 1061: Call to a possibly undefined method getChildAt through a reference with static type Class.

Main class:

package  {
    import flash.display.MovieClip;
    import flash.events.Event;
    
    public class Main extends MovieClip {
        
        private var BtnL_:BtnLmc;
        private var BtnR_:BtnRmc;

        public function Main() {
            stop();
            //add class BtnLmc
            BtnL_ = new BtnLmc();
            BtnL_.x = 143,3;
            BtnL_.y = 111,3;
            addChild(BtnL_);
            //add class BtnRmc
            BtnR_ = new BtnRmc();
            BtnR_.x = 641,2;
            BtnR_.y = 111,3;
            addChild(BtnR_);
            
            this.addEventListener(Event.ADDED_TO_STAGE, toStage, false, 0, true);
        }
        private function toStage(event:Event):void {
            this.removeEventListener(Event.ADDED_TO_STAGE, toStage);
            stage.addEventListener(Event.ENTER_FRAME, onEnter, false, 0, true);
        }
        //add actions at specific frame 
        private function onEnter(event:Event):void {
            var frame:Number;
            frame = currentFrame;
            switch (frame) {
                case 1 :
                stop();
                BtnR_.visible = true;
                BtnL_.visible = true;
                break;
                case 10 :
                gotoAndStop(11);
                BtnR_.visible = true;
                BtnL_.visible = true;
                break;
                case 20 :
                gotoAndStop(21);
                BtnR_.visible = true;
                BtnL_.visible = true;
                break;
                case 30 :
                gotoAndStop(31);
                BtnR_.visible = true;
                BtnL_.visible = true;
                break;
                case 40 :
                gotoAndStop(41);
                BtnR_.visible = true;
                BtnL_.visible = true;
                break;
                case 50 :
                gotoAndStop(51);
                BtnR_.visible = true;
                BtnL_.visible = true;
                break;
                case 60 :
                gotoAndStop(61);
                BtnR_.visible = true;
                BtnL_.visible = true;
                break;
                case 70 :
                gotoAndStop(71);
                BtnR_.visible = true;
                BtnL_.visible = true;
                break;
                case 80 :
                gotoAndStop(1);
                BtnR_.visible = true;
                BtnL_.visible = true;
                break;
                case 90 :
                gotoAndStop(71);
                BtnR_.visible = true;
                BtnL_.visible = true;
                break;
                case 100 :
                gotoAndStop(61);
                BtnR_.visible = true;
                BtnL_.visible = true;
                break;
                case 110 :
                gotoAndStop(51);
                BtnR_.visible = true;
                BtnL_.visible = true;
                break;
                case 120 :
                gotoAndStop(41);
                BtnR_.visible = true;
                BtnL_.visible = true;
                break;
                case 130 :
                gotoAndStop(31);
                BtnR_.visible = true;
                BtnL_.visible = true;
                break;
                case 140 :
                gotoAndStop(21);
                BtnR_.visible = true;
                BtnL_.visible = true;
                break;
                case 150 :
                gotoAndStop(11);
                BtnR_.visible = true;
                BtnL_.visible = true;
                break;
                case 160 :
                gotoAndStop(1);
                BtnR_.visible = true;
                BtnL_.visible = true;
                break;
            }
        
        }

    }
    
}

BtnLmc class:

package  {
    
    import flash.display.MovieClip;
    import flash.ui.Mouse;
    import flash.events.MouseEvent;
    import flash.events.Event;
    import flash.display.Stage;
    import flash.display.DisplayObject;
    
    public class BtnLmc extends MovieClip {
        
        private var BtnR:BtnRmc = new BtnRmc();
        private var BtnL1:Object = this.getChildAt(3);
        private var BtnL2:Object = this.getChildAt(2);
        private var BtnL3:Object = this.getChildAt(1);
        private var BtnL4:Object = this.getChildAt(0);
        private var BtnR1:Object = BtnR.getChildAt(3);

        private var buttonsAr:Array = [this.BtnL1, this.BtnL2, this.BtnL3, this.BtnL4, this];
        
        public function BtnLmc() {
            // constructor code
            BtnL2.name = "BtnL2";
            BtnL3.name = "BtnL3";
            BtnL4.name = "BtnL4";
            setButtons();
        }
        private function setButtons():void {
            for (var i:int = 0; i < buttonsAr.length; i++) {
                //set the buttons of array
                buttonsAr*.buttonMode = true;
                buttonsAr*.mouseChildren = true;
                buttonsAr*.mouseEnabled = true;
                //listeners to array of buttons
                buttonsAr*.addEventListener(MouseEvent.ROLL_OVER, playOver, false, 0, true);
                buttonsAr*.addEventListener(MouseEvent.ROLL_OUT, playOut, false, 0, true);
                buttonsAr*.addEventListener(MouseEvent.CLICK, doClick, false, 0, true);
            }
        }
        private function playOver(event:MouseEvent):void {
            //child - button state "over"
            event.currentTarget.gotoAndStop("over");
        }
        private function playOut(event:MouseEvent):void {
            //child - button state "out"
            event.currentTarget.gotoAndPlay("out");
        }
        private function doClick(event:MouseEvent):void {
            //if any button is "down" make it back to "up" 
            function setSelectedBtn():void {
                for (var i:int=0; i< buttonsAr.length; i++) {
                    if (buttonsAr*.currentLabel == "down"){
                        buttonsAr*.gotoAndStop("up");
                        buttonsAr*.buttonMode = true;   
                        buttonsAr*.mouseEnabled = true;   
                        buttonsAr*.mouseChildren = true;
                    }
                }
            }
            //if left button clicked make his (right) neighbor button "down"
            if (event.target.name == "BtnL2") {
                this.BtnL1.gotoAndStop("down");
                this.BtnL1.buttonMode = false;
                this.BtnL1.mouseEnabled = false;
                this.BtnL1.mouseChildren = false;
            }
            else if (event.target.name == "BtnL3") {
                this.BtnL2.gotoAndStop("down");
                this.BtnL2.buttonMode = false;
                this.BtnL2.mouseEnabled = false;
                this.BtnL2.mouseChildren = false;
            }
            else if (event.target.name == "BtnL4") {
                 this.BtnL3.gotoAndStop("down");
                this.BtnL3.buttonMode = false;
                this.BtnL3.mouseEnabled = false;
                this.BtnL3.mouseChildren = false;
            }
            else {
                BtnR.BtnR1.gotoAndStop("down");
                BtnR.BtnR1.buttonMode = false;
                BtnR.BtnR1.mouseEnabled = false;
                BtnR.BtnR1.mouseChildren = false;
            }
            //make parents unvisible to show stage animation
            BtnR.visible = false;
            this.visible = false;
            switch (currentLabel) {
            //to add some other actions at specific root label
                case "first" :
                break;
                case "second" :
                break;
                case "third" :
                break;
                case "fourth" :
                break;
                case "fiveth" :
                break;
                case "sixth" :
                break;
                case "seventh" :
                break;
                case "eight" :
                break;
            }
        //play animation till the next label
        play();
        }

    }    

}

BtnRmc class:

package  {
    
    import flash.display.MovieClip;
    import flash.ui.Mouse;
    import flash.events.MouseEvent;
    import flash.events.Event;
    import flash.display.Stage;
    import flash.display.DisplayObject;
    
    public class BtnRmc extends MovieClip {
        
        private var BtnL:BtnLmc = new BtnLmc();
        private var BtnR1:Object = this.getChildAt(3);
        private var BtnR2:Object = this.getChildAt(2);
        private var BtnR3:Object = this.getChildAt(1);
        private var BtnR4:Object = this.getChildAt(0);
        private var BtnL1:Object = BtnL.getChildAt(3);

        private var buttonsAr:Array = [this.BtnR1, this.BtnR2, this.BtnR3, this.BtnR4, this];
        
        public function BtnRmc() {
            // constructor code
            BtnR2.name = "BtnR2";
            BtnR3.name = "BtnR3";
            BtnR4.name = "BtnR4";
            setButtons();
        }
        private function setButtons():void {
            for (var i:int = 0; i < buttonsAr.length; i++) {
                //set the buttons of array
                buttonsAr*.buttonMode = true;
                buttonsAr*.mouseChildren = true;
                buttonsAr*.mouseEnabled = true;
                //listeners to buttons of array
                buttonsAr*.addEventListener(MouseEvent.ROLL_OVER, playOver, false, 0, true);
                buttonsAr*.addEventListener(MouseEvent.ROLL_OUT, playOut, false, 0, true);
                buttonsAr*.addEventListener(MouseEvent.CLICK, doClick, false, 0, true);
            }
        }
        private function playOver(event:MouseEvent):void {
            //child - button state "over"
            event.currentTarget.gotoAndStop("over");
        }
        private function playOut(event:MouseEvent):void {
            //child - button state "out"
            event.currentTarget.gotoAndPlay("out");
        }
        private function doClick(event:MouseEvent):void {
            //if any button is "down" make it back to "up" 
            function setSelectedBtn():void {
                for (var i:int=0; i< buttonsAr.length; i++) {
                    if (buttonsAr*.currentLabel == "down"){
                        buttonsAr*.gotoAndStop("up");
                        buttonsAr*.buttonMode = true;   
                        buttonsAr*.mouseEnabled = true;   
                        buttonsAr*.mouseChildren = true;
                    }
                }
            }
            //if right button clicked make his (left) neighbor button "down"
            if (event.target.name == "BtnR2") {
                this.BtnR1.gotoAndStop("down");
                this.BtnR1.buttonMode = false;
                this.BtnR1.mouseEnabled = false;
                this.BtnR1.mouseChildren = false;
                }
            else if (event.target.name == "BtnR3") {
                this.BtnR2.gotoAndStop("down");
                this.BtnR2.buttonMode = false;
                this.BtnR2.mouseEnabled = false;
                this.BtnR2.mouseChildren = false;
            }
            else if (event.target.name == "BtnR4") {
                this.BtnR3.gotoAndStop("down");
                this.BtnR3.buttonMode = false;
                this.BtnR3.mouseEnabled = false;
                this.BtnR3.mouseChildren = false;
                }
                else {
                BtnL.BtnL1.gotoAndStop("down");
                BtnL.BtnL1.buttonMode = false;
                BtnL.BtnL1.mouseEnabled = false;
                BtnL.BtnL1.mouseChildren = false;
            }
            //make parents unvisible to show stage animation
            this.visible = false;
            BtnL.visible = false;
            switch (currentLabel) {
                case "first" :
                gotoAndPlay(83);
                break;
                case "second" :
                gotoAndPlay(153);
                break;
                case "third" :
                gotoAndPlay(143);
                break;
                case "fourth" :
                gotoAndPlay(133);
                break;
                case "fiveth" :
                gotoAndPlay(123);
                break;
                case "sixth" :
                gotoAndPlay(113);
                break;
                case "seventh" :
                gotoAndPlay(103);
                break;
                case "eight" :
                gotoAndPlay(93);
                break;
            }

        }

    }
    
}

Thank You for any guidance!

Regards,
Domen