0 Replies Latest reply on Apr 29, 2012 9:51 AM by fallinginreverse

    can anyone help? - exit buttons

    fallinginreverse

      i have a deadline for an assignment tomorrow. the sub movies are loading without any problem but the exit buttons on the loaded swfs are not working. can any help? my code is the following and i'd appreciate it if someone could help:



      monkey_btn.addEventListener(MouseEvent.MOUSE_DOWN, buttonPressed);

      zebra_btn.addEventListener(MouseEvent.MOUSE_DOWN, buttonPressed);

      penguin_btn.addEventListener(MouseEvent.MOUSE_DOWN, buttonPressed);

      lion_btn.addEventListener(MouseEvent.MOUSE_DOWN, buttonPressed);

      gallery_btn.addEventListener(MouseEvent.MOUSE_DOWN, buttonPressed);

      video_btn.addEventListener(MouseEvent.MOUSE_DOWN, buttonPressed);

      //set the variable to record the name of the button pressed;

      var button:String = "empty";

      //-----------------------------------------------------------------------------

      // function to record which button pressed

      function buttonPressed(event:Event):void

      {

       

                if (event.target.name == "monkey_btn")

                {

                button = "monkeysub";

                }

                else if

       

                           (event.target.name == "zebra_btn")

                          {

                                    button = "zebrasub";

                }

       

       

                          else if

       

                           (event.target.name == "penguin_btn")

                          {

                                    button = "penguinsub";

                }

       

                          else if

       

                          (event.target.name == "lion_btn")

                          {

                                    button = "lionsub";

                }

       

                else if

       

                          (event.target.name == "gallery_btn")

                          {

                                    button = "picture gallery";

                }

       

                else if

       

                          (event.target.name == "video_btn")

                          {

                                    button = "videosub";

                }

       

       

       

                // the next statement closes the if }

       

       

      // add a trace statement to test which button name is recorded

      trace(button);

      //calls the deactivateButtons function

      deactivateButtons();

       

       

       

       

      // the next statement closes the function }

      }

      //---------------------------------------------------

      //Now we need to create our addMovie function:

      //define a loader to load the movie to the stage

      var movieLoader:Loader = new Loader();

       

       

      function addMovie()

      {

      //define the movie to load

      var movieRequest:URLRequest = new URLRequest(button+".swf");

      //Set the loaders load property to the var movieRequest

      movieLoader.load(movieRequest);

      //add the movie to the stage;

      addChild(movieLoader);

      //set its x and y positions

      movieLoader.x=0;

      movieLoader.y=0;

       

       

      }

       

       

      //function to deactivate the buttons

      //function to call the addMovie and deactivate the buttons

      function deactivateButtons()

      {

      // disables the buttons

      monkey_btn.mouseEnabled = false;

      zebra_btn.mouseEnabled = false;

      penguin_btn.mouseEnabled = false;

      lion_btn.mouseEnabled = false;

      gallery_btn.mouseEnabled = false;

      video_btn.mouseEnabled = false;

      addMovie();

      }

       

       

       

       

       

       

       

       

      //function to remove the loaded movie and reactivate the

      //buttons this function is called by the child loaded through

      //the addMovie function

      function activateButtons()

      {

      removeChild(movieLoader);

      // enables the buttons

      monkey_btn.mouseEnabled = true;

      zebra_btn.mouseEnabled = true;

      penguin_btn.mouseEnabled = true;

      lion_btn.mouseEnabled = true;

      gallery_btn.mouseEnabled = true;

      video_btn.mouseEnabled = true;

      }