# How do i access a function in the main class from another class?

**URL:** <https://forum.kirupa.com/t/how-do-i-access-a-function-in-the-main-class-from-another-class/305655>\
**Category:** Uncategorized\
**Created:** [March 1, 2010, 1:26pm UTC](https://forum.kirupa.com/t/how-do-i-access-a-function-in-the-main-class-from-another-class/305655 "2010-03-01T13:26:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nlween](https://avatars.discourse-cdn.com/v4/letter/n/ac91a4/32.png) [@nlween](https://forum.kirupa.com/u/nlween)\
**Post date:** [March 1, 2010, 1:26pm UTC](https://forum.kirupa.com/t/how-do-i-access-a-function-in-the-main-class-from-another-class/305655/1 "2010-03-01T13:26:44Z")

</div>

i am new to as3. i have a game that i want to put load screen on, which i created a separate class for. first the main class is initialized and in the constructor function, it does an addChild(loadScreen) which places an instance of the loadScreen MC on the stage. within the loadScreen is a “Play Button” that when a user presses this button i want it to continue startGame in the Main class. the way i tried it was Main.startGame from the loadScreen class, but that obviously does not work. is it possible to call a function from a different class, or is there just a simpler way of doing this that i am missing?

i have three files:  
Main.fla  
Main.as  
loadScreen.as

the Main.as file:

```auto

package
{
    import flash.text.*;
    import flash.display.*;
    import flash.events.*;
    
    public class Main extends Sprite
    {
        var startPage:loadScreen = new loadScreen();
        
        public function Main()
        {
            addChild(startPage);
           
        }

        public function startGame()
        {
           // The meat of the code for the game is here
        }

     }
}

```

the loadScreen.as file:

```auto
package {
    import flash.text.*;
    import flash.display.*;
    import flash.events.*;

    public class loadScreen extends MovieClip {

        public function loadScreen() {
            bLoad.buttonMode=true;
            bLoad.addEventListener(MouseEvent.CLICK,playGame);
        }
        public function playGame(e:MouseEvent) {
            
            Memory.startGame(); // <----- SOMETHING THAT DOES THIS
        }
    }
}

```
