# Exernal class problem

**URL:** <https://forum.kirupa.com/t/exernal-class-problem/318622>\
**Category:** flash\
**Created:** [January 25, 2011, 3:40pm UTC](https://forum.kirupa.com/t/exernal-class-problem/318622 "2011-01-25T15:40:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sanzochan](https://avatars.discourse-cdn.com/v4/letter/s/f17d59/32.png) [@sanzochan](https://forum.kirupa.com/u/sanzochan)\
**Post date:** [January 25, 2011, 3:40pm UTC](https://forum.kirupa.com/t/exernal-class-problem/318622/1 "2011-01-25T15:40:58Z")

</div>

The logic behind what I want to do is very, very simple but somehow it just doesn’t work.

Ok, I have this Main.fla and my Main.as which is the Class Document. In the Main.fla, I have a button in the library whose class is HomeBtn.as. Inside this HomeBtn.as, I have an event listener where the user clicks the button, it will bring the player back to the home page.

In my Main.as, I have a function called gotoFrame, which goes to the frame and does its respective functions.

```auto

private function gotoFrame(frame:String):void
        {
            gotoAndStop(frame);
            
            if (this.currentLabel == "preload")
            {
                trace("Currently at preload");
                
                doPreload();
            }
            else if (this.currentLabel == "storefront")
            {
                trace("Currently at storefront");
                
                gotoStoreFront();
            }
            else if (this.currentLabel == "insideStore")
            {
                trace("Currently inside store");
                
                gotoInsideStore();
            }
        }

```

and so, I’m trying to call this function (which is in the Main.as), from my HomeBtn.as, but somehow it’s not working. My HomeBtn.as:

```auto

package
{
    import flash.display.*;
    import flash.events.*;
    import Main;
    
    public class HomeBtn extends SimpleButton
    {
        
        public function HomeBtn()
        {
            this.addEventListener(MouseEvent.CLICK, gotoFrontStore);
        }
        
        public function gotoFrontStore(e:MouseEvent):void
        {
            this.removeEventListener(MouseEvent.CLICK, gotoFrontStore);
            
            root.gotoFrame("storefront");
        }
    }
}

```

I don’t think I’m doing it correctly, and this simple problem is driving me nuts. Hope someone can help!
