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.
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:
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!