0
votes

I am using Flash Professional CS6/AS3 to make a simple game. I want a back button, that when clicked takes the player back to the intro screen. Everything else works, but the button will not show on the screen and it will not function when I drag it onto the screen and click it. The back_Btn class is empty and the symbol contains no timeline code.

There are no error messages. I want to reiterate that everything else is working perfectly.
Here's the document class:

package 
{
    import com.greensock.TweenLite;
    import com.greensock.*;
    import com.greensock.easing.*;
    import flash.display.MovieClip;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.display.Stage;
    import flash.display.SimpleButton;

    public class Main extends MovieClip
    {
        var back1:back_Btn;
        var intro:introScreen;
        var game:levelOne;
        var stageRef:Stage;
        //
        var timer:Number = 0;
        var holder:int = 0;
        var boolean:Boolean = false;
        var speed:int;
        //
        public function Main()
        {

            init();
        }
        function init():void
        {
            stageRef = stage;
            back1 = new back_Btn();
            stageRef.addChild(back1);
            //
            game = new levelOne();
            //
            intro = new introScreen();
            stageRef.addChild(intro);
            //
            back1.x = 425;
            back1.y = 0;
            intro.x = 0;
            intro.y = 0;

            intro.lampBtn.addEventListener(MouseEvent.CLICK,startGame);
            addEventListener(Event.ENTER_FRAME,startApp);
            back1.addEventListener(MouseEvent.CLICK,exitGame);

            speed = 0;

            function startApp(evt:Event):void
            {

                intro.x +=  speed;
                if ((boolean == true))
                {
                    speed = 5;
                    boolean = false;
                }

            }
        }
        function startGame(evt:Event):void
        {
            game = new levelOne  ;
            stageRef.addChild(game);
            game.x = 0;
            game.y = 0;
            boolean = true;
        }
        function exitGame(evt:Event):void
        {
            trace("back button clicked");
            removeChild(game);
            addChild(intro);
            intro.visible = true;
        }

    }
}

When not dragged onto the stage, the button doesn't appear. When dragged on, the trace statement doesn't fire when clicked and nothing happens. Very strange.

1
If your back_Btn is empty you cannot see it as there is nothing to see. Besides you addChild 'game' on top of back1. Intro is also on top.SzRaPnEL
You got it. I thought the script above is over and below is lower. Below is on top. I swore I tried that but at that point I must have been running into some other error. I've been at this almost all night. Annoying little quirks. Thanks a million. You should post your comment as the answer.Syed

1 Answers

1
votes

If your back_Btn is empty you cannot see it as there is nothing to see. Besides you addChild 'game' on top of back1. Intro is also on top.