3 Replies Latest reply: Dec 24, 2011 8:35 AM by kglad RSS

    Navigating using a loader script and how to modify script to use labels instead of frame numbers?

    marisol_Q Community Member

      Hello,

       

      This is my first Flash portfolio, so please bear with me. I have 4 layers: Home (frames 1-19); images and navigation buttons (frames 20-40) that contains a loader with 10 sub-layers, click a button and user navigates to separate and distinct clips; and experience (frames 41-60). If I use the script below, will it work properly? I added stops in the script because if I didn't, I would get endless looping between frames.

       

      And, how do I modify script below to say: home instead of frame 1? And, if I want to add a hyperlink mailto:, how do I add a subject line and a bcc address? I selected my email, highlighted it and enter the mailto: line, with target as _blank

       

      Thanks very much.

       

      ---------------------------------------------

       

      stop();

       

      import flash.display.Loader;

      import flash.events.MouseEvent;

      import flash.net.URLRequest;

       

      var myLoader:Loader = new Loader();

       

      swf1.addEventListener(MouseEvent.CLICK, loadMySWF);

      swf2.addEventListener(MouseEvent.CLICK, loadMySWF);

      swf3.addEventListener(MouseEvent.CLICK, loadMySWF);

      swf4.addEventListener(MouseEvent.CLICK, loadMySWF);

      swf5.addEventListener(MouseEvent.CLICK, loadMySWF);

      swf6.addEventListener(MouseEvent.CLICK, loadMySWF);

      swf7.addEventListener(MouseEvent.CLICK, loadMySWF);

      swf8.addEventListener(MouseEvent.CLICK, loadMySWF);

       

      function loadMySWF(event:MouseEvent):void{

          var newPage:URLRequest = new URLRequest(event.target.name +".swf");

          myLoader.load(newPage);

          addChild(myLoader);

      }

       

      stop();

       

      home_btn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_1);

       

      function fl_ClickToGoToAndStopAtFrame_1(event:MouseEvent):void

      {

          gotoAndStop(1);

      }

       

      stop();

       

      experience_btn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_41);

       

      function fl_ClickToGoToAndStopAtFrame_41(event:MouseEvent):void

      {

          gotoAndStop(41);

      }

       

      stop();

        • 1. Re: Navigating using a loader script and how to modify script to use labels instead of frame numbers?
          kglad CommunityMVP

           

          stop();

           

          import flash.display.Loader;

          import flash.events.MouseEvent;

          import flash.net.URLRequest;

           

          var myLoader:Loader = new Loader();

           

          swf1.addEventListener(MouseEvent.CLICK, loadMySWF);

          swf2.addEventListener(MouseEvent.CLICK, loadMySWF);

          swf3.addEventListener(MouseEvent.CLICK, loadMySWF);

          swf4.addEventListener(MouseEvent.CLICK, loadMySWF);

          swf5.addEventListener(MouseEvent.CLICK, loadMySWF);

          swf6.addEventListener(MouseEvent.CLICK, loadMySWF);

          swf7.addEventListener(MouseEvent.CLICK, loadMySWF);

          swf8.addEventListener(MouseEvent.CLICK, loadMySWF);

           

          function loadMySWF(event:MouseEvent):void{

              var newPage:URLRequest = new URLRequest(event.target.name +".swf");

              myLoader.load(newPage);

              addChild(myLoader);

          }

           

          stop();

           

          home_btn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_1);

           

          function fl_ClickToGoToAndStopAtFrame_1(event:MouseEvent):void

          {

              gotoAndStop("home");

          }

           

          stop();

           

          experience_btn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_41);

           

          function fl_ClickToGoToAndStopAtFrame_41(event:MouseEvent):void

          {

              gotoAndStop(41);

          }

           

          stop();

           

          user's default email program (if they have one):

           

          navigateToURL(new URLRequest("mailto:somebody@anywhere.com?cc=cc@anywhere.com&bcc=bcc@anywhere.com&subject=I am the email subject&body=I am the email body"));

          • 2. Re: Navigating using a loader script and how to modify script to use labels instead of frame numbers?
            marisol_Q Community Member

            Thanks. I feel more confident now that you've reviewed my script. Final question to clarify. Is this how I would use the label instead of a frame number?

             

            stop();

             

            home_btn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStop"home");

             

            function fl_ClickToGoToAndStopAt"home"(event:MouseEvent):void

            {

                gotoAndStop("home");

            }

            • 3. Re: Navigating using a loader script and how to modify script to use labels instead of frame numbers?
              kglad CommunityMVP

              no, just use the code i suggested.  you're getting confused by a function name:

               

              // this

              home_btn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_1);

               

              function fl_ClickToGoToAndStopAtFrame_1(event:MouseEvent):void

              {

                  gotoAndStop("home");

              }

               

              // works the same as

               

              home_btn.addEventListener(MouseEvent.CLICK, f);

               

              function f(event:MouseEvent):void

              {

                  gotoAndStop("home");

              }

               

              // use any function name you find helpful (and that hasn't been used before)