5 Replies Latest reply on Jul 19, 2007 11:06 PM by Newsgroup_User

    ARGH! PAGE CHANGE!

    IMDaNuBe
      Hello Forums:

      Here's a link to the package of files I've been working on, and it has been causing me a tremendous amount of grief.

      http://www.clanna.com/aux/Flash.zip

      What I'm trying to do is that every single page is its own movie clip (To reduce loading times), as a child clipunder DOCK.swf (which is the main flash file). Clicking on a button inside the MENU clip will change the page. Can someone point me on how to do this?

      Note: Each CHILD CLIP actually has 2 parts; the first 25 frames of intro animation, stop on frame 26, then, 25 MORE frames of ending animation. Therefore, when a user clicks on a button, the currently loaded clip would play the LAST 25 frames, then the next one is loaded and played.

      Thank you in advance.

        • 1. Re: ARGH! PAGE CHANGE!
          Level 7
          Hi IMDaNuBe,

          If I understand correctly, you really just want to attach clips
          dynamically rather than loading them as SWFs, correct? To achieve this,
          here are the steps you'll need to take:

          1. Create a new layer on the main timeline (above Layer 12, for
          example). Position it so that it appears where you want it to.
          2. Create a new movie clip on that layer. Give it the instance name
          "contentHolder". Position it, keeping in mind that the point is the
          upper-left hand corner of the clip. You may want to put a temporary
          graphic in the movie to help you move it around.
          3. Create all of your child content clips. Basically, create new symbols
          and put your animations into each one...all frames you need, content, etc.
          4. Upon creating each one, give it a unique linkage ID. To do this,
          right-click on the item in the library, select "Linkage...", select the
          "Export for ActionScript" check box, and give it an identified in the
          "Identifier" box. This can be anything you like but must be unique for
          each clip.
          5. Go into your menu. On each button you will need to attach code that
          will attach the specified content. Let's say your house button "loads"
          the clip with the linkage ID "house". The code on the button will look
          like this:
          on (press) {
          _root.switchContent("house");
          }
          6. Now it gets tricky because we define the roll-in, roll-out animation
          handler and content switcher. You can add this code on the main timeline
          or anywhere else you want:

          _root.switchContent=function(linkageID) {
          _root.tempID=linkageID;
          _root.swapContents=function() {
          _root.contentHolder.attachMovie(_root.tempID);
          }
          _root.contentHolder.onEnterFrame=function() {
          if (this._currentframe<this._totalframes) {
          this.stop();
          _root.swapContents();
          }
          }
          _root.contentHolder.play();
          }

          It's a little thick but it should live nicely in a package no matter
          where you put it. Basically, when you call this from the button, it
          stores the linkage ID in a _root value and then defines two functions.
          The first function swaps content in the contentHolder using the value
          you just stored. We do this so that this function isn't accidentally
          killed when the content is playing. The second function monitor the
          content clip as it plays and when it has reached the end, it stops
          itself and swaps itself out using the function we defined in the
          previous sentence. Finally, we get the show rolling by playing the
          content clip.

          Due to this structure, you need to ensure that your content clips do the
          following: Automatically play through on the timeline to frame 25 (or
          wherever) and then stop. After that, it should have no stops or other
          timeline controls. This function and your button will define when this
          gets triggered. Frame 26 can be the content frame, and frame 27 to 50
          can be the fade out frame.

          Hope this helps.

          Regards,
          Patrick



          IMDaNuBe wrote:
          > Hello Forums:
          >
          > Here's a link to the package of files I've been working on, and it has been
          > causing me a tremendous amount of grief.
          >
          > http://www.clanna.com/aux/Flash.zip
          >
          > What I'm trying to do is that every single page is its own movie clip (To
          > reduce loading times), as a child clipunder DOCK.swf (which is the main flash
          > file). Clicking on a button inside the MENU clip will change the page. Can
          > someone point me on how to do this?
          >
          > Note: Each CHILD CLIP actually has 2 parts; the first 25 frames of intro
          > animation, stop on frame 26, then, 25 MORE frames of ending animation.
          > Therefore, when a user clicks on a button, the currently loaded clip would play
          > the LAST 25 frames, then the next one is loaded and played.
          >
          > Thank you in advance.
          >
          >
          >

          --
          http://www.baynewmedia.com
          Faster, easier, better...ActionScript development taken to new heights.
          Download the BNMAPI today. You'll wonder how you ever did without it!
          Available for ActionScript 2.0/3.0.
          • 2. Re: ARGH! PAGE CHANGE!
            IMDaNuBe Level 1
            Hello:

            Thank you for your time and response. It is much appreciated!

            However, just off to the side, if I DO want to use individual .swf rather than movie clips, what should I do? I'd kinda prefer that my users load each embedded swf on demand rather than having them in movie clips and load all together.

            Thanks you very much!
            • 3. Re: ARGH! PAGE CHANGE!
              Level 7
              Hi,

              Well, may I suggest you use my API? Visit http://www.baynewmedia.com/
              and have a look at the ActionScript 2.0 section. The sticky post has a
              link to the API. There's a Flash 8 FLA there that shows you how to
              instantiate the API. Two lines of code and you have everything. From
              there on in, here's what you'll need to do:

              1. Create the content holder clip on your root timeline like before.
              Call it "contentHolder".
              2. Create your content clips. They should play automatically to your
              "stop" frame (25 or whatever). On that frame, add the following code
              (assuming you've included the API in your code):

              function continue(eventObj) {
              this.play();
              }
              _global.API.addEventListener(this.continue,this,'Content.CONTINUE',null,true);

              2. On the last frame of your content clips, add the following code:

              _global.API.broadcast({message:'Content.GETNEXT',sender:this});
              stop();

              3. On the main timeline, add the following code:

              _root.getNext=function(eventObj) {
              _root.contentHolder.loadMovie(_root.contentPath);
              }
              _global.API.addEventListener(_root.getNext,_root,'Content.GETNEXT',null,false);

              4. And finally, add the code to each of your menu buttons to trigger the
              sequence:

              _root.contentPath='somefile.swf';
              _global.API.broadcast({message:'Content.CONTINUE',sender:this});

              Running through the sequence: You click on a button and it sets the
              content path to some SWF file you want to load. The API the broadcasts
              to something out there in the aether that is listening for the message
              "Content.CONTINUE" (step 4). As it so happens, your loaded clip is
              listening for that content and it triggers the "continue" function which
              simply causes the clip to play (step 2). The clip plays through to the
              end, stops, and broadcasts another message, "Content.GETNEXT" (step 2).
              There's an event listener created at step 3 which is hooked up to the
              function _root.getNext. This simply uses the existing clip to load
              content from the path you specified in the first step (step 4 in the
              list), which loads and adds itself as a listener and the whole thing is
              primed and ready to go for the next one.

              Again, you WILL need the BNMAPI for this to work. Simply download it and
              instantiate it on the first line of your FLA:

              import com.bnm.BNMAPI;
              _global.API=new BNMAPI();

              And you're done!

              Regards,
              Patrick

              --
              http://www.baynewmedia.com
              Faster, easier, better...ActionScript development taken to new heights.
              Download the BNMAPI today. You'll wonder how you ever did without it!
              Available for ActionScript 2.0/3.0.


              IMDaNuBe wrote:
              > Hello:
              >
              > Thank you for your time and response. It is much appreciated!
              >
              > However, just off to the side, if I DO want to use individual .swf rather than
              > movie clips, what should I do? I'd kinda prefer that my users load each
              > embedded swf on demand rather than having them in movie clips and load all
              > together.
              >
              > Thanks you very much!
              >

              • 4. Re: ARGH! PAGE CHANGE!
                IMDaNuBe Level 1
                Thank you. Your time is appreciated.

                I will link credits to your site once my site has been completed. Thank you once again.
                • 5. Re: ARGH! PAGE CHANGE!
                  Level 7
                  No need but thanks all the same. Let me know how you're making out. The
                  API is intended to be very hardy so if you're having problems with it I
                  should be able to help you out quickly.

                  Patrick

                  IMDaNuBe wrote:
                  > Thank you. Your time is appreciated.
                  >
                  > I will link credits to your site once my site has been completed. Thank you once again.

                  --
                  http://www.baynewmedia.com
                  Faster, easier, better...ActionScript development taken to new heights.
                  Download the BNMAPI today. You'll wonder how you ever did without it!
                  Available for ActionScript 2.0/3.0.