# Ending the use of a class within AS3

**URL:** https://forum.kirupa.com/t/ending-the-use-of-a-class-within-as3/327980
**Category:** flash
**Created:** [April 10, 2012, 7:36pm UTC](https://forum.kirupa.com/t/ending-the-use-of-a-class-within-as3/327980 "2012-04-10T19:36:25Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Campbells](https://avatars.discourse-cdn.com/v4/letter/c/c6cbf5/32.png) [@Campbells](https://forum.kirupa.com/u/Campbells)
#### Post date: [April 10, 2012, 7:36pm UTC](https://forum.kirupa.com/t/ending-the-use-of-a-class-within-as3/327980/1 "2012-04-10T19:36:25Z")

</div>

Hi Kirupa members,

Long time reader, first time posting so hope my etiquette is in order.

I have a program I am building that at the moment has two classes (more to add in later), a main class and a visual training class. The main class contains the main menu and the visual training is one of the links.

I introduce the visual training class from the main class like so:

```auto
/*---------------------------------------------------------
        VISUAL TRAINING ELEMENT
        ---------------------------------------------------------*/
        var training:VisualTraining; //declare the viusal training object

public function Main() 
        {
            /*-----------------------------------------------------
            DEFINE ITEMS
            -----------------------------------------------------*/
training = new VisualTraining();
}

```

And this is the call that starts the functions within the Visual Training Class

```auto
        function callVisualTrainingClass():void{
            addChild(training);
            training.startVisualTraining();
        }

```

This works fine in that the Visual Training class is called and the program steps through with no errors. The problem I have is ending the invlovement of the visual training class and returning to the main class.

```auto
//navigational buttons for visual training
                right_btn = new RightButton;
                right_btn.x = 510;
                right_btn.y = 630;
                right_btn.buttonMode = true;
                addChild(right_btn);

/* ----------------------------------------------------------
            RELOADS THE MAIN MENU SO THAT THE USER CAN RESTART
            ------------------------------------------------------------*/
            function backToMain(e:MouseEvent):void
            {
                returnHome_btn.removeEventListener(MouseEvent.CLICK, backToMain);
                removeChild(returnHome_btn);
            
                //removeChild(training);
                //mainMenu();
            }

```

I have created a home button with a call to a backToMain function, how do I get this function to remove the visual training element from the stage???
