0

I just started using the document class in flash cs6 today...

so I learned how to put things on the stage and remove it...but if I make a chain of it it doesn't really work and gives me an error here this is what I mean...

    public var playbtn:SimpleButton;
    public var loadbtn:SimpleButton;
    public var backbtn:SimpleButton;

        public function SkoolBook() {

            playbtn = new play_button;
            addChild(playbtn);
            playbtn.x=200;
            playbtn.y=200;

            playbtn.addEventListener(MouseEvent.CLICK, playbutton);

            function playbutton (MouseEvent) {
                removeChild (playbtn);
                loadbtn = new load1;
                addChild(loadbtn);
                loadbtn.x=500;
                loadbtn.y=500;


            loadbtn.addEventListener(MouseEvent.CLICK, loadbutton);
                  function loadbutton (MouseEvent) {
                removeChild (loadbtn);
                backbtn = new back_button;
                addChild(backbtn);
                backbtn.x=500;
                backbtn.y=500;
        }

            }

so umm yah I just want a ssimple event that if I click on the play button that button disappears and the load button comes up..and if I click on the load button then my first stage comes up......

is there something here I am misunderstanding... why is this giving me an error?

can somebody please exaplin how to exactly carry out sequences in document class....

tailedmouse
  • 365
  • 3
  • 16

2 Answers2

2

This should do it.
If not post the errors.

package{
  import flash.events.MouseEvent;

  public class SkoolBook{
    public var playbtn:SimpleButton = new play_button();
    public var loadbtn:SimpleButton = new load1();
    public var backbtn:SimpleButton = new back_button();

      public function SkoolBook() {
          addChild(playbtn);
          playbtn.x=200;
          playbtn.y=200;

          playbtn.addEventListener(MouseEvent.CLICK, playbutton);
      }
      public function playbutton (evt:MouseEvent) {
            removeChild (playbtn);
            addChild(loadbtn);
            loadbtn.x=500;
            loadbtn.y=500;
            loadbtn.addEventListener(MouseEvent.CLICK, loadbutton);
      }
      public function loadbutton (evt:MouseEvent) {
            removeChild (loadbtn);
            addChild(backbtn);
            backbtn.x=500;
            backbtn.y=500;
            // don't forget to add the backbtn function
            //backbtn.addEventListener(MouseEvent.CLICK, XXXXXXXX);
    }

}

The_asMan
  • 6,364
  • 4
  • 23
  • 34
0

You'll get errors from having MouseEvent all alone in your function definitions:

function playbutton (MouseEvent)

Should be:

function playbutton (mEvent:MouseEvent)

This way, your function playbutton has a name (mEvent) to represent the instance of the MouseEvent that is being passed into it. You'll have to do the same for function loadbutton (MouseEvent).

If you continue to get errors, please be more descriptive and include the error text so it's easier to help :]

Foggzie
  • 9,691
  • 1
  • 31
  • 48
  • I see thank u good fella :D I have a question I am making an interactive fiction (so like a digital comic with a lot of choices and things..ummm somethinglike Zork) is it more logical to use the time line than the document class? its a lot of choices... – tailedmouse Jan 02 '13 at 21:58
  • Well, the "Document Class" is just a subclass of the `MovieClip` object that serves as actionscript’s entry point into your project. You'll be fine using it instead of throwing code into the first frame of the timeline. – Foggzie Jan 02 '13 at 22:09
  • I see...but which one will be more efficient and easier? – tailedmouse Jan 02 '13 at 22:12
  • Easier: Document Class, More Efficient: I have no idea :P – Foggzie Jan 02 '13 at 22:22