15 Replies Latest reply on May 23, 2006 7:51 AM by Newsgroup_User

    NewbieQ--simple slide presentation--previous?

    Dick Margulis
      I thought I'd start with something really, really simple as my first project. I have a slide presentation consisting of two slides (so far).

      I created two buttons, LeftArrow and RightArrow. I placed the RightArrow button on Slide 1 and both buttons on Slide 2 . I gave each instance a unique name. I used the Behaviors window to apply canned actions to the buttons. The Go To Next Slide action attached to the RightArrow button works on slide 1, but the Go To Previous Slide action attached to the LeftArrow button on Slide 2 does nothing.

      The script checker shows no errors (not surprising given that I didn't write the scripts).

      What should I be looking for?

      Thanks!
        • 1. Re: NewbieQ--simple slide presentation--previous?
          Level 7
          Dick,

          > I gave each [button] instance a unique name. I used the
          > Behaviors window to apply canned actions to the buttons.
          > The Go To Next Slide action attached to the RightArrow
          > button works on slide 1, but the Go To Previous Slide
          > action attached to the LeftArrow button on Slide 2 does
          > nothing.

          Show us what ActionScript the Behavior actually wrote into your button.
          Select the button instance, open your Actions panel, and you should see a
          bit of ActionScript in there.

          > The script checker shows no errors (not surprising given
          > that I didn't write the scripts).
          >
          > What should I be looking for?

          As soon as I see that ActionScript, I may be able to help you -- or I'll
          at least know what additional questions to ask you.


          David
          stiller (at) quip (dot) net
          Dev essays: http://www.quip.net/blog/
          "Luck is the residue of good design."


          • 2. Re: NewbieQ--simple slide presentation--previous?
            Dick Margulis Level 1
            quote:

            Originally posted by: Newsgroup User
            Dick,


            As soon as I see that ActionScript, I may be able to help you -- or I'll
            at least know what additional questions to ask you.

            Here's the script:

            on (release) {

            // GoTo Previous Screen behavior
            var screen = null;
            var target = this;
            while((screen == null) && (target != undefined) && (target != null))
            {
            if(target instanceof mx.screens.Screen)
            {
            screen = target;
            }
            else
            {
            target = target._parent;
            }
            }
            if(screen instanceof mx.screens.Slide)
            {
            screen.rootSlide.currentSlide.gotoPreviousSlide();
            }
            // End GoTo Previous Screen behavior


            This appears to be identical to the generated script for Got To Next Screen, except for the final function, of course.


            David
            stiller (at) quip (dot) net
            Dev essays: http://www.quip.net/blog/
            "Luck is the residue of good design."





            • 3. Re: NewbieQ--simple slide presentation--previous?
              Level 7
              Dick,

              >> As soon as I see that ActionScript, I may be able to
              >> help you -- or I'll at least know what additional questions
              >> to ask you.

              > Here's the script:
              >
              > on (release) {
              >
              > // GoTo Previous Screen behavior

              Aha, we're dealing with Screens! Okay, this is complicates things. I
              realize it doesn't seem like it should be complicated, because you've barely
              added anything to your FLA, but unbeknownst to you, there is now 27KB worth
              of "stuff" in your published SWF, on top of whatever your images weigh. (I
              assume you went to File > New, then picked Flash Slide Presentation?) For
              fun, run a quick test. Create a new Slide Presentation or Form Application,
              then test it and look at the file size of the "empty" SWF: 27KB. Do the
              same with a Flash Document ... file size: 34 bytes.

              I personally prefer not to use the Screens functionality of Flash. It's
              relatively new, and there's a Screens framework that gets installed in order
              to make the normal Timeline interface seem like, well, like a bunch of
              Screens or Forms (that's the 27KB). Meanwhile, the Timeline metaphor has
              been around since the beginning.

              Note, you haven't done a thing wrong, here. Not a thing. It's just
              that I prefer the Timeline way of doing things (File > New, then Flash
              Document). In my experience, Scenes only make things more complicated than
              they need to be. For example, in a normal Flash movie, you could import one
              image to frame 1, another to frame 2, then attach the following code to each
              button:

              // Button 1
              on (release) {
              nextFrame();
              }

              // Button 2
              on (release) {
              prevFrame();
              }

              Pretty easy, right?


              David
              stiller (at) quip (dot) net
              Dev essays: http://www.quip.net/blog/
              "Luck is the residue of good design."


              • 4. Re: NewbieQ--simple slide presentation--previous?
                Dick Margulis Level 1
                quote:

                Originally posted by: Newsgroup User


                Note, you haven't done a thing wrong, here. Not a thing. It's just
                that I prefer the Timeline way of doing things (File > New, then Flash
                Document). In my experience, Scenes only make things more complicated than
                they need to be. For example, in a normal Flash movie, you could import one
                image to frame 1, another to frame 2, then attach the following code to each
                button:

                // Button 1
                on (release) {
                nextFrame();
                }

                // Button 2
                on (release) {
                prevFrame();
                }

                Pretty easy, right?

                Okay, I'll try that. Looks pretty simple. Thanks for the guidance.
                • 5. Re: NewbieQ--simple slide presentation--previous?
                  Dick Margulis Level 1
                  quote:

                  Originally posted by: Newsgroup User
                  Dick,


                  Note, you haven't done a thing wrong, here. Not a thing. It's just
                  that I prefer the Timeline way of doing things (File > New, then Flash
                  Document). In my experience, Scenes only make things more complicated than
                  they need to be. For example, in a normal Flash movie, you could import one
                  image to frame 1, another to frame 2, then attach the following code to each
                  button:

                  // Button 1
                  on (release) {
                  nextFrame();
                  }

                  // Button 2
                  on (release) {
                  prevFrame();
                  }

                  Pretty easy, right?


                  David,

                  I tried your suggestion. The back button still doesn't do anything, and now I have the additional problem of a movie that wants to advance automatically at the frame rate, which I set to the minimum of 0.01 fps, but that's not going to do the trick. I want the user to control the advance to the next slide/frame/whichever. So how do I make that happen?

                  Dick
                  • 6. Re: NewbieQ--simple slide presentation--previous?
                    Level 7
                    Dick,

                    > I tried your suggestion. The back button still doesn't do
                    > anything, and now I have the additional problem of a
                    > movie that wants to advance automatically at the frame
                    > rate

                    Ah, no problem. Flash lets you put code in more than one kind of place.
                    So far, you've been putting code directly onto buttons. You can also put
                    code in frames. So create a new layer just for scripts -- better to keep
                    things neat and orderly -- and click inside frame 1. Add this single
                    ActionScript function:

                    stop();

                    That will stop the main timeline from advancing on its own.

                    Next, we'll need to see what's going on with the buttons. Since your
                    "previous" button doesn't work, your "next" button may not, either.

                    In my head, I'm imagining that you have a layer for ActionScript (named
                    "scripts"), a layer for your graphics, with graphic A in frame 1 and graphic
                    B in frame 2, and a layer for your buttons.

                    The buttons should be button symbols (not graphics or movie clips). You
                    should click on each button to select it and paste the previously suggested
                    code, as appropriate, on each button.

                    Let me know if this is what you have, and we'll work from there.


                    David
                    stiller (at) quip (dot) net
                    Dev essays: http://www.quip.net/blog/
                    "Luck is the residue of good design."


                    • 7. Re: NewbieQ--simple slide presentation--previous?
                      Dick Margulis Level 1
                      quote:

                      Originally posted by: Newsgroup User
                      Dick,
                      Ah, no problem. Flash lets you put code in more than one kind of place.
                      So far, you've been putting code directly onto buttons. You can also put
                      code in frames. So create a new layer just for scripts -- better to keep
                      things neat and orderly -- and click inside frame 1. Add this single
                      ActionScript function:

                      stop();

                      Dick>> Do I put that in every frame, as I add frames? Or just in the first?



                      That will stop the main timeline from advancing on its own.

                      Next, we'll need to see what's going on with the buttons. Since your
                      "previous" button doesn't work, your "next" button may not, either.

                      In my head, I'm imagining that you have a layer for ActionScript (named
                      "scripts"), a layer for your graphics, with graphic A in frame 1 and graphic
                      B in frame 2, and a layer for your buttons.

                      The buttons should be button symbols (not graphics or movie clips). You
                      should click on each button to select it and paste the previously suggested
                      code, as appropriate, on each button.

                      Let me know if this is what you have, and we'll work from there.


                      Dick>> That's what I have now (not what I had before). Before I had the buttons on the same layer with the graphics.

                      The new symptom, aside from the back button not working, now the keyboard left and right arrow keys don't work either (they did previously). I have to select Play on the Flash player context menu to get back to the first graphic.

                      The button scripts are on the button layer, not on the scripts layer.

                      Do the buttons persist, or do I need to put a new pair of buttons on each frame and give them unique names?






                      • 8. Re: NewbieQ--simple slide presentation--previous?
                        Level 7
                        Dick,

                        >> Add this single ActionScript function:
                        >>
                        >> stop();

                        > Dick>> Do I put that in every frame, as I add
                        > frames? Or just in the first?

                        Once is good enough. The timeline stops when you invoke the stop()
                        function and plays when you invoke the play() function. Since your buttons
                        invoke nextFrame() and prevFrame(), the timeline won't start playing again
                        (as it would, for example, if you used gotoAndPlay(2)).

                        > Dick>> That's what I have now (not what I had
                        > before). Before I had the buttons on the same
                        > layer with the graphics.

                        In truth, all of these things *could* be in the same layer, but I find
                        movies easier to edit when everything -- or groups of things -- are located
                        on their own layers. In some cases, such as with tweens, objects must
                        occupy their own layer.

                        > The new symptom, aside from the back button
                        > not working, now the keyboard left and right arrow
                        > keys don't work either (they did previously).

                        That came from the Screens overhead, then -- part of that extra 27KB
                        worth of ActionScript that was built in from the get-go. In a Flash
                        Document (versus a Slideshow), you're starting from scratch, so if you want
                        arrow key functionality, you'll have to roll your own.

                        Now, that said, it may make more sense for you after all to use Screens.
                        I only played around with them when they were first introduced as a feature,
                        so maybe they offer even more that I don't know about. (I hate to steer you
                        in more than one direction, so I hope I'm not muddying the water for you!)

                        If you want to stick with the Flash Document (the timeline metaphor),
                        I'm happy to keep troubleshooting.

                        > I have to select Play on the Flash player context
                        > menu to get back to the first graphic.

                        You won't have to when your buttons are working.

                        > The button scripts are on the button layer, not
                        > on the scripts layer.

                        And that makes perfect sense, for the method you're using, which is the
                        on() event handler (direct attachment to a button).

                        > Do the buttons persist, or do I need to put a
                        > new pair of buttons on each frame and give
                        > them unique names?

                        The only name that has to be unqiue is a button's instance name. An
                        instance name is something you give to a button via the Properties
                        inspector. The button symbol itself has a Library name, which is different.
                        You could drag two copies of a Library button symbol onto the Stage and give
                        each copy its own instance name.

                        As it turns out, you don't even need instance names when you use the
                        on() event handler. The reason for this is because you're attaching code
                        directly to the button itself, so there's no doubt which object is intended
                        recipient of your instructions.

                        First, let's make sure your buttons are responding at all. In your
                        "previous" button, change your code to this:

                        on (release) {
                        trace("previous");
                        prevFrame();
                        }

                        ... and change your "next" button's code to this:

                        on (release) {
                        trace("next");
                        nextFrame();
                        }

                        When you test your movie and click the buttons, you should see
                        "previous" and "next," respectively, in the Output panel, which will open on
                        its own in order to display its messages.


                        David
                        stiller (at) quip (dot) net
                        Dev essays: http://www.quip.net/blog/
                        "Luck is the residue of good design."


                        • 9. Re: NewbieQ--simple slide presentation--previous?
                          Dick Margulis Level 1
                          Once is good enough. The timeline stops when you invoke the stop()
                          function and plays when you invoke the play() function. Since your buttons
                          invoke nextFrame() and prevFrame(), the timeline won't start playing again
                          (as it would, for example, if you used gotoAndPlay(2)).

                          DICK>>>> That makes sense. Thanks.

                          [snip]

                          Now, that said, it may make more sense for you after all to use Screens.
                          I only played around with them when they were first introduced as a feature,
                          so maybe they offer even more that I don't know about. (I hate to steer you
                          in more than one direction, so I hope I'm not muddying the water for you!)

                          DICK>>>> No. This is great. I was running in circles trying to follow the tutorials in the Help file (I hope Adobe reengineers the Help system for this product). You're making perfect sense, and I really appreciate this.


                          [snip]

                          > Do the buttons persist, or do I need to put a
                          > new pair of buttons on each frame and give
                          > them unique names?

                          The only name that has to be unqiue is a button's instance name. An
                          instance name is something you give to a button via the Properties
                          inspector. The button symbol itself has a Library name, which is different.
                          You could drag two copies of a Library button symbol onto the Stage and give
                          each copy its own instance name.

                          As it turns out, you don't even need instance names when you use the
                          on() event handler. The reason for this is because you're attaching code
                          directly to the button itself, so there's no doubt which object is intended
                          recipient of your instructions.

                          DICK>>>> Yes, I understand about where to do the naming; and I understand that I don't need to name the buttons in this simple case. I still have the same question, though: Once I've created the buttons in their own layer, do I have to create new ones for each frame, or can I just let the original pair persist as the graphics in the graphic layer keep swapping out? Right now I've defined a key frame for the first frame, with just a Next button, and another key frame in frame 2, with both buttons. Can I just leave that alone until I get to the final frame, where I'll only have a Previous button?

                          First, let's make sure your buttons are responding at all. In your
                          "previous" button, change your code to this:

                          on (release) {
                          trace("previous");
                          prevFrame();
                          }

                          ... and change your "next" button's code to this:

                          on (release) {
                          trace("next");
                          nextFrame();
                          }

                          When you test your movie and click the buttons, you should see
                          "previous" and "next," respectively, in the Output panel, which will open on
                          its own in order to display its messages.


                          DICK>>>> I see "next" trace, but the Previous button isn't working.

                          Couple of off-the-wall questions:

                          1. I'm using the latest, greatest, updatedest version of Flash Professional 8 on Win XP Professional (and I've rebooted a couple of times in the middle of this conversation, just for the fun of it). Is it possible this is just something that happens to be broken in that version? In other words, have you actually tried the Previous button on your system and are you using the same version?

                          2. Is there some preference setting somewhere that could be causing this behavior?

                          3. Is there a news server interface to this forum? I find typing in this Web interface awkward at best.


                          Dick
                          • 10. Re: NewbieQ--simple slide presentation--previous?
                            Level 7
                            Dick,

                            > Once is good enough. The timeline stops when you
                            > invoke the stop() function and plays when you invoke
                            > the play() function.

                            >> DICK>>>> That makes sense. Thanks.

                            > Now, that said, it may make more sense for you after
                            > all to use Screens.

                            > > DICK>>>> No. This is great. [...] You're making
                            > perfect sense, and I really appreciate this.

                            Glad to hear that. We'll continue on, then.

                            > DICK>>>> Once I've created the buttons in their own
                            > layer, do I have to create new ones for each frame, or
                            > can I just let the original pair persist as the graphics in
                            > the graphic layer keep swapping out?

                            Ahh, sorry about that. You did ask that, plain and simple, and I
                            rambled on a bit without answering it. This is one of the reasons why the
                            concept of separate layers is a good thing.

                            By all means, put your buttons in once and leave them. They do persist,
                            and the ActionScript you attach to them stays put until you change it.
                            Changes occur on keyframes, and if your buttons were on the same layer as
                            your images, the keyframing might make it easier to accidentally change or
                            delete the ActionScript on a given frame for your buttons.

                            > Right now I've defined a key frame for the first frame,
                            > with just a Next button, and another key frame in frame
                            > 2, with both buttons.

                            That makes sense. As you continue to add images, one per frame, just
                            add frames to your button layer to ensure they span the same number of
                            frames. Each frame on your image layer will be a keyframe, but you'll only
                            have a keyframe on your button layer in frame 1, frame 2, and your last
                            frame, where the change will be that it only contains the "previous" button.

                            > Can I just leave that alone until I get to the final frame,
                            > where I'll only have a Previous button?

                            Ha! Same wavelength. You nailed it.

                            > First, let's make sure your buttons are responding at all.
                            > In your "previous" button, change your code to this:
                            > [trace() statement]

                            >> DICK>>>> I see "next" trace, but the Previous button
                            >> isn't working.

                            Okay, that's helpful. Now we can narrow our focus down to the
                            "previous" button. At this point, my questions include: a) how are these
                            two buttons different?, b) are they both button symbols?

                            >> Couple of off-the-wall questions:
                            >
                            > 1. I'm using the latest, greatest, updatedest version of
                            > Flash Professional 8 on Win XP Professional [...] Is it
                            > possible this is just something that happens to be broken
                            > in that version?

                            No, not at all. The sort of ActionScript we're using has been available
                            since Flash 2, I think, and works in all versions since.

                            > In other words, have you actually tried the Previous
                            > button on your system and are you using the same
                            > version?

                            I was stepping through this in my head, actually. But to make sure
                            neither of us is going batty, I created a quick test. Works just fine, and
                            I'm also on Flash 8 Professional, WinXP Pro.

                            > 2. Is there some preference setting somewhere that could
                            > be causing this behavior?

                            Not that I can think of. I think you have something wrong with your
                            button.

                            > 3. Is there a news server interface to this forum? I find
                            > typing in this Web interface awkward at best.

                            Ha! You bet. I prefer a news reader myself. Point your news client to
                            forums.macromedia.com.


                            David
                            stiller (at) quip (dot) net
                            Dev essays: http://www.quip.net/blog/
                            "Luck is the residue of good design."


                            • 11. Re: NewbieQ--simple slide presentation--previous?
                              Level 7
                              David Stiller wrote:
                              > Dick,

                              > Okay, that's helpful. Now we can narrow our focus down to the
                              > "previous" button. At this point, my questions include: a) how are these
                              > two buttons different?, b) are they both button symbols?

                              First, thanks for the news server tip. This is MUCH better. I can
                              breathe again.

                              The buttons are identical graphics (one is rotated 180 degrees), listed
                              in the Library with different names, LeftArrow and RightArrow, both
                              identified as of the Button type, and I get no errors on either when I
                              check the scripts, which I copied from your post and pasted directly
                              into the script window.

                              Here's the Previous script again, copied out of the script window, just
                              for verification purposes:

                              // Button 2
                              on (release) {
                              trace("previous");
                              prevFrame();
                              }

                              It's like the release event isn't being recognized. Yet, if I turn on
                              Enable Simple Buttons in the Control menu, both buttons work just fine
                              in the stage area. I can click them and navigate from frame to frame.
                              It's only in the .swf that the one button refuses to work.

                              Aha! A thought. Maybe the fact there are only two frames is a problem.
                              Nope. Just tested that. Added a third frame and nothing changed.

                              Dick
                              • 12. Re: NewbieQ--simple slide presentation--previous?
                                Level 7
                                Dick,

                                > First, thanks for the news server tip. This is MUCH
                                > better. I can breathe again.

                                You bet! I rarely use the web version. Somes it's good for searching,
                                but even then, I tend to use Google Groups.

                                > The buttons are identical graphics (one is rotated 180
                                > degrees), listed in the Library with different names,
                                > LeftArrow and RightArrow, both identified as of the
                                > Button type, and I get no errors on either when I check
                                > the scripts

                                At this point, I'm starting to say, "Hmmm."

                                > It's like the release event isn't being recognized. Yet, if
                                > I turn on Enable Simple Buttons in the Control menu, both
                                > buttons work just fine in the stage area. I can click them
                                > and navigate from frame to frame. It's only in the .swf
                                > that the one button refuses to work.

                                Wow. Now I'm really curious.

                                > Aha! A thought. Maybe the fact there are only two frames
                                > is a problem. Nope. Just tested that. Added a third frame
                                > and nothing changed.

                                Well, I don't often ask to see a person's FLA, but if you're willing to
                                send me a copy, I'll take a look. There must be something amiss that
                                neither of us sees. If you're unwilling or can't send your FLA (sometimes
                                people aren't allowed to share work-related files), I recommend you save
                                your current FLA and start a new one ... in case, for some reason, you have
                                a corrupted file on your hands.

                                See if you can create a single button that does nothing but step
                                backwards. Should be straightfoward ... say, a 10-frame movie with a
                                keyframe in frame 10 that says this.stop();, and a button whose attached
                                code says ...

                                on (release) {
                                trace("previous");
                                prevFrame();
                                }


                                David
                                stiller (at) quip (dot) net
                                Dev essays: http://www.quip.net/blog/
                                "Luck is the residue of good design."


                                • 13. Re: NewbieQ--simple slide presentation--previous?
                                  Level 7
                                  Quick follow-up ...

                                  > Well, I don't often ask to see a person's FLA, but if you're
                                  > willing to send me a copy, I'll take a look. There must be
                                  > something amiss that neither of us sees.

                                  As it turns out, something about Dick's "previous" button was corrupt.
                                  Unexplainable fluke. He started again with a new FLA, following the advice
                                  above, and found success.


                                  David
                                  stiller (at) quip (dot) net
                                  Dev essays: http://www.quip.net/blog/
                                  "Luck is the residue of good design."


                                  • 14. Re: NewbieQ--simple slide presentation--previous?
                                    SeedofHope Level 1
                                    OK. I have a follow up to this.

                                    I will be using Slides or Screens. I know how to get my external SWF loaded into either.

                                    However, how do you get it to advance to the next Slide or Screen, once the SWF loaded into the current Slide or Screen is finished?

                                    Thanks in advance,
                                    Loren
                                    • 15. Re: NewbieQ--simple slide presentation--previous?
                                      Level 7
                                      Loren,

                                      > I will be using Slides or Screens. I know how to get my external
                                      > SWF loaded into either.

                                      So far, so good.

                                      > However, how do you get it to advance to the next Slide or
                                      > Screen, once the SWF loaded into the current Slide or Screen
                                      > is finished?

                                      You've described two goals, here. First, how to advance Slides or
                                      Screens; second, how to determine when an external SWF has completely
                                      loaded. To answer the first, I recommend the "Screen class" and "Slide
                                      class" entries of the ActionScript 2.0 Language Reference (documentation
                                      that ships with Flash). With a big of digging, these will provide all the
                                      information you need, though they're differently arranged from other class
                                      entries in the docs.

                                      Classes define objects in ActionScript, and almost everything usable in
                                      Flash can be described as an object. Generally speaking, class entries
                                      display one or more categories that summarize an object's properties
                                      (characteristics it has), methods (things it can do), and events (things it
                                      can react to) -- which, in effect, gives you an Owner's Manual for the
                                      object in question, for everything from movie clips (the MovieClip class),
                                      dynamic and input text fields (TextField class), and so on, including
                                      screens and slides.

                                      For details on tackling the AS 2.0 Language Reference, see this article
                                      ...

                                      http://www.communitymx.com/content/article.cfm?cid=01B54

                                      That said, for some reason, some classes are arranged into wordier,
                                      essay style configurations. These include the topics at hand. The general
                                      principles apply, though, so don't be swayed.

                                      As for determining when an external SWF had completely loaded, check out
                                      the following article.

                                      http://www.quip.net/blog/2006/flash/how-to-tell-when-external-swf-loaded


                                      David
                                      stiller (at) quip (dot) net
                                      Dev essays: http://www.quip.net/blog/
                                      "Luck is the residue of good design."