17 Replies Latest reply on Feb 3, 2009 7:02 AM by Newsgroup_User

    parent script and step frame

    Level 7
      I realize that there are various ways to do this but I've already taken this
      path and would like to try to work it out. I have a message box that
      appears at the beginning of my program. I'm using a child object to
      generate it. I know that any navigation in the stepFrame handler is
      ignored, right? Is there a way to have the playback head stay on one frame
      from the parent script outside of creating a repeat loop in the stepFrame
      method?

      Craig


        • 1. Re: parent script and step frame
          Production Monkey Level 3
          Are you trying to create a program with no sprites in the score?

          To keep the play head on one frame use an exitFrame handler in a Movie script

          on exitframe
          go the frame
          end

          I'm curious as to why you would want to use stepFrame for a "message box"?
          • 2. Re: parent script and step frame
            Level 7
            I don't thinkthere is any problem using navigation like 'go to the
            frame' in stepFrame handlers. I think I have used that before. But if
            it does not work, you can always put a sprite on the stage (even if it
            is physically past the boundaries of the stage) with a script like this:

            ----

            property pHold

            on beginSprite me
            pHold=0
            end

            on holdNow me
            pHold=1
            end

            on stopHolding me
            pHold=0
            end

            on exitFrame me
            if pHold then go to the frame
            end

            ----

            Then, in your parent script, when you want it to start holding, do:

            sendAllSprites(#holdNow)

            and when you want it to be able to move again, do this:

            sendAllSprites(#stopHolding)
            • 3. Re: parent script and step frame
              Level 7
              I remember running into that issue before. I'm fairly certain one can't use
              "go to" in a parent script. Of course, it's pretty hard to screw up a "go
              to" statement so if it's not happening when the movie runs it's probably not
              allowed.

              I chose to use a parent script so that I didn't have to have a sprite
              running through all of my movies within this project...or have a shared
              cast. I find it so much cleaner to do it this way so that those scripts are
              just hanging out there in global variables. I can instantiate it in the
              first movie and it's there. It's purely a style choice and of course like
              most things in programming, there are many ways to skin the cat.

              Also, I am making a few changes to a bunch of pretty complicated educational
              CD's and this method minimizes the amount of changes I need to make to the
              score and scripts, minimizing the amount of testing needed.

              Mike, I did end up using something like what you posted, more or less a
              switch.

              Thanks

              --
              Craig S. Wollman

              Word of Mouth Productions
              159-00 Riverside Drive West
              New York, New York 10032
              (212) 928-9581
              "WOMP" <forums@wordofmo.com> wrote in message
              news:glnbof$lj7$1@forums.macromedia.com...
              >I realize that there are various ways to do this but I've already taken
              >this path and would like to try to work it out. I have a message box that
              >appears at the beginning of my program. I'm using a child object to
              >generate it. I know that any navigation in the stepFrame handler is
              >ignored, right? Is there a way to have the playback head stay on one frame
              >from the parent script outside of creating a repeat loop in the stepFrame
              >method?
              >
              > Craig
              >


              • 4. Re: parent script and step frame
                Production Monkey Level 3
                "I'm fairly certain one can't use "go to" in a parent script."

                Really?

                Did you take two minutes out of your life to make a test? Did you have a real question?

                And, shared casts are your very good friend. Only a fool would choose not to use them.
                • 5. Re: parent script and step frame
                  Level 7
                  Sarcasm is only asking for a bitter responses from people in this forum.
                  "fool"? If you can't keep your personal baggage out of this forum then stay
                  out. Are you specifically looking for a rise out of me? You've suceeded.

                  Of course I made a test. Why would I ask if I hadn't. I guess the better
                  question would be did YOU make a test.

                  You cannot use a "go to the frame" in a stepFrame script. Period. Other
                  types of navigation are allowed.. Of course, I specifically asked whether
                  there was a way to keep the playback head on a frame from parent script.

                  I've been using Director since 1991 and I have contributed hundreds of
                  answers here. Nobody needs your attitude but I especially don't apprecitate
                  it. And your completely closed minded comment about shared casts gives away
                  your age and lack of experience.


                  --
                  Craig


                  "Production Monkey" <webforumsuser@macromedia.com> wrote in message
                  news:glta9q$ape$1@forums.macromedia.com...
                  > "I'm fairly certain one can't use "go to" in a parent script."
                  >
                  > Really?
                  >
                  > Did you take two minutes out of your life to make a test? Did you have a
                  > real
                  > question?
                  >
                  > And, shared casts are your very good friend. Only a fool would choose not
                  > to
                  > use them.
                  >


                  • 6. Re: parent script and step frame
                    Level 7
                    I don't want to jump into the flame war here, but I just ran a test, and
                    here it is:

                    Make a simple new movie with 2 frames, each with a

                    on exitFrame me
                    go to the frame
                    end

                    Name one of the frames (the second one) "test"

                    Make the following parent script named "test"

                    on new me
                    (the actorList).add(me)
                    return me
                    end

                    on stepFrame me
                    go "test"
                    end

                    --

                    Hit Play, and in the message window, type

                    script("test").new()

                    et voila. The playhead jumps to the test frame. Sarcasm and general
                    asshattery aside, you can go to a frame in a stepFrame handler.
                    • 7. Re: parent script and step frame
                      Level 7
                      Yes, Mike. I also ran that test. But what I mentioned that you can't do is
                      a frame loop within the stepFrame handler. Try go to the frame and see if
                      the playback head stays on a frame. I think you'll find that it won't.

                      Thanks for putting the time in to test that.

                      An interesting phenomenon that I found...If you put a go to the frame in an
                      exitFrame handler in frame 20 then put marker "test" in frame 5. Then,
                      using your stepFrame handler, the playback head stops (or loops) on frame 6,
                      not 5! That's bazaar. I'm sure maybe Sean Wilson will have an explanation
                      for that one.

                      My original problem was not being able to create a frame loop using the
                      stepFrame handler. With a kludgy fix, I could put a marker on the frame
                      before the one I want to loop on and use your example modified as above. An
                      elegant solution using only go to the frame in a stepFrame handler just
                      won't work.

                      --
                      Craig

                      "Mike Blaustein" <mblaustein@gmail.com> wrote in message
                      news:gltfkg$gur$1@forums.macromedia.com...
                      >I don't want to jump into the flame war here, but I just ran a test, and
                      >here it is:
                      >
                      > Make a simple new movie with 2 frames, each with a
                      >
                      > on exitFrame me
                      > go to the frame
                      > end
                      >
                      > Name one of the frames (the second one) "test"
                      >
                      > Make the following parent script named "test"
                      >
                      > on new me
                      > (the actorList).add(me)
                      > return me
                      > end
                      >
                      > on stepFrame me
                      > go "test"
                      > end
                      >
                      > --
                      >
                      > Hit Play, and in the message window, type
                      >
                      > script("test").new()
                      >
                      > et voila. The playhead jumps to the test frame. Sarcasm and general
                      > asshattery aside, you can go to a frame in a stepFrame handler.


                      • 8. Re: parent script and step frame
                        Level 7
                        > I'm sure maybe Sean Wilson will have an explanation
                        > for that one.

                        :-) Nope - got me beat. Your follow-up observations are interesting though!
                        • 9. Re: parent script and step frame
                          Level 7

                          "Craig Wollman" <craig@wordofmo.com> wrote in message
                          news:gltlfo$nfs$1@forums.macromedia.com...
                          > Yes, Mike. I also ran that test. But what I mentioned that you
                          > can't do is a frame loop within the stepFrame handler. Try go to
                          > the frame and see if the playback head stays on a frame. I think
                          > you'll find that it won't.

                          <snip>

                          Could it be that "the frame" is not defined at the moment the
                          stepFrame occurs?
                          I mean: it is after "exitFrame", and before "enterFrame".

                          Technically speaking the stepFrame would exactly be "between" two
                          frames, and not in either of those 2.

                          Richard


                          • 10. parent script and step frame
                            fazstp Level 2
                            <oops double post>
                            • 11. Re: parent script and step frame
                              fazstp Level 2
                              What about something like

                              property p_hold_frame

                              on new me
                              p_hold_frame = _movie.frame -1
                              return me
                              end

                              on stepFrame me
                              _movie.go( p_hold_frame )
                              end


                              One thing I noticed is that using the go from a stepFrame fires an extra prepareFrame and enterFrame event. According to the docs the sequence is stepFrame, prepareFrame, enterFrame, exitFrame.

                              • 12. Re: parent script and step frame
                                Level 7
                                Interesting. I'll try your suggestion. Of course this is all a workaround
                                for something that is not quite consistent with Director's typical or
                                expected performance.

                                I'm curious about why this works this way but in any case I'll test it...

                                I have to admit, after using Lingo for 16 years, I made a choice to stay
                                with the older dot syntax. I'm not much of a Flash user, although I'm
                                diving into ActionScript 3.0. So I'll have to do a bit of adjusting in your
                                solution. I purchased D11 but always end up using D9 because it opens so
                                much faster than newer versions (I suppose because of the Javascript loading
                                overhead.)

                                So there's an extra enter and prepare frame fired? Wow. That could be
                                because the playback head does reach the marker as intended then jumps to
                                the next frame so in fact a command to go to a particular marker actually
                                covers two frames rather than one.

                                My original intention was to have the playback head hold anytime the
                                global/object is added to the actorList. If I have to use anything outside
                                of the child object, I have to place it wherever it's needed. I think one
                                of the advantages of the OOP/Parent-child relationship is that the
                                programmer can effect change from manipulating a global rather than
                                hardcoding actions within the score.

                                Thanks for your help
                                --
                                Craig

                                "fazstp" <webforumsuser@macromedia.com> wrote in message
                                news:glu19j$6vu$1@forums.macromedia.com...
                                > What about something like
                                >
                                > on new me
                                > p_hold_frame = _movie.frame -1
                                > return me
                                > end
                                >
                                > on stepFrame me
                                > _movie.go( p_hold_frame )
                                > end
                                >
                                >
                                > One thing I noticed is that using the go from a stepFrame fires an extra
                                > prepareFrame and enterFrame event. According to the docs the sequence is
                                > stepFrame, prepareFrame, enterFrame, exitFrame.
                                >
                                >
                                >


                                • 13. Re: parent script and step frame
                                  Level 7
                                  It's a logical explanation and I should be able to test that with "put the
                                  frame" in the stepFrame handler before and after the go to sytax.

                                  --
                                  Craig

                                  "LOOPING_Richard" <root@localhost.not> wrote in message
                                  news:gltpe0$rph$1@forums.macromedia.com...
                                  >
                                  > "Craig Wollman" <craig@wordofmo.com> wrote in message
                                  > news:gltlfo$nfs$1@forums.macromedia.com...
                                  >> Yes, Mike. I also ran that test. But what I mentioned that you can't do
                                  >> is a frame loop within the stepFrame handler. Try go to the frame and
                                  >> see if the playback head stays on a frame. I think you'll find that it
                                  >> won't.
                                  >
                                  > <snip>
                                  >
                                  > Could it be that "the frame" is not defined at the moment the stepFrame
                                  > occurs?
                                  > I mean: it is after "exitFrame", and before "enterFrame".
                                  >
                                  > Technically speaking the stepFrame would exactly be "between" two frames,
                                  > and not in either of those 2.
                                  >
                                  > Richard
                                  >


                                  • 14. parent script and step frame
                                    Production Monkey Level 3
                                    Perhaps I can redeem myself for my “asshattery” by providing some solutions. Here are three Parent scripts that will pause the play head.

                                    1. By exploiting a side effect of using timeout objects, an “exitFrame” method can be added to a global script object and you can thereby turn on or off whether the exitframe method is called or not.

                                    Usage:
                                    gPlayHead = script(“Playhead Pause”).new()
                                    gPlayHead.pause()
                                    gPlayHead.continue()


                                    -- Playhead pause

                                    property pTimeOb

                                    on new me
                                    return me
                                    end

                                    on pause me
                                    pTimeOb = timeout().new("pause_"&me, 0, #update, me)
                                    end

                                    on continue me
                                    if pTimeOb.objectP then
                                    pTimeOb.forget()
                                    pTimeOb = 0
                                    end if
                                    end

                                    on exitframe me
                                    go the frame
                                    end
                                    --------------------------------------------

                                    2. Dynamically create a Movie script with an exitFrame-go-the-frame function.

                                    Usage:
                                    gPlayHead = script(“Playhead Pause”).new()
                                    gPlayHead.pause()
                                    gPlayHead.continue()

                                    -- Playhead Pause

                                    property pLoopScript

                                    on new me
                                    return me
                                    end

                                    on pause me
                                    pLoopScript = new(#script)
                                    pLoopScript.scriptType = #Movie
                                    Code = "on exitframe " & Return & "go the frame" & Return & "end"
                                    pLoopScript.scriptText = Code
                                    end

                                    on continue me
                                    pLoopScript.erase()
                                    pLoopScript = void
                                    end
                                    --------------------------------------------------------------

                                    3. If your Message Object places one or more sprites on the stage then you can provide the appropriate interface and add the object to the sprite's scriptInstanceList.

                                    Usage:
                                    gMessage = script("Message").new()
                                    gMessage.show()

                                    -- message

                                    property pMessageSprite

                                    on new me
                                    return me
                                    end new

                                    on show me
                                    TextMem = new(#Text)
                                    TextMem.text = "Click To Close."
                                    TextMem.width = 150

                                    pMessageSprite = sprite(1)
                                    pMessageSprite.puppet = true
                                    pMessageSprite.member = TextMem
                                    pMessageSprite.loc = point(200,100)
                                    pMessageSprite.scriptInstancelist.add(me)
                                    end

                                    on mouseUp me
                                    pMessageSprite.member.erase()
                                    pMessageSprite.puppet = false
                                    end

                                    on exitFrame me
                                    go the frame
                                    end
                                    • 15. Re: parent script and step frame
                                      fazstp Level 2
                                      quote:

                                      Originally posted by: Production Monkey
                                      2. Dynamically create a Movie script with an exitFrame-go-the-frame function.



                                      It never occurred to me that exitFrame would work in a movie script. If that's the case you could always use a global flag.

                                      global g_hold_frame

                                      on exitFrame
                                      if ( g_hold_frame = TRUE ) then
                                      _movie.go( _movie.frame )
                                      end if
                                      end

                                      • 16. Re: parent script and step frame
                                        Level 7
                                        Adding an exitFrame to the movieScript would be fine but my intention was to
                                        not add any code to any existing scripts in this project. It was done many
                                        years ago and the budget to update the programs and add one piece of
                                        functionality doesn't include any testing time. I'm not altruistic enough
                                        to do that testing for free so I need to be able to do my work and do just
                                        enough testing to feel confident in what I've done. My code must be as
                                        unintrusive as possible. That is why I was trying to do everything from a
                                        parent script. Being able to stall the playback head from a child object
                                        just by invoking a method through a global variable would allow me to
                                        accomplish this (among other things in that script). By taking in all the
                                        info you've all presesented here, I've been able to accomplish what I set
                                        out to do.

                                        Thanks a lot.

                                        Craig

                                        --
                                        > It's a logical explanation and I should be able to test that with "put the
                                        > frame" in the stepFrame handler before and after the go to sytax.
                                        >
                                        > --
                                        > Craig
                                        >
                                        > "LOOPING_Richard" <root@localhost.not> wrote in message
                                        > news:gltpe0$rph$1@forums.macromedia.com...
                                        >>
                                        >> news:gltlfo$nfs$1@forums.macromedia.com...
                                        >>> Yes, Mike. I also ran that test. But what I mentioned that you can't
                                        >>> do is a frame loop within the stepFrame handler. Try go to the frame
                                        >>> and see if the playback head stays on a frame. I think you'll find that
                                        >>> it won't.
                                        >>
                                        >> <snip>
                                        >>
                                        >> Could it be that "the frame" is not defined at the moment the stepFrame
                                        >> occurs?
                                        >> I mean: it is after "exitFrame", and before "enterFrame".
                                        >>
                                        >> Technically speaking the stepFrame would exactly be "between" two frames,
                                        >> and not in either of those 2.
                                        >>
                                        >> Richard
                                        >>
                                        >
                                        >


                                        • 17. Re: parent script and step frame
                                          Level 7
                                          Thanks Mr. Monkey for the info and thanks for taking the high road.

                                          Craig


                                          "Production Monkey" <webforumsuser@macromedia.com> wrote in message
                                          news:gm7aem$p66$1@forums.macromedia.com...
                                          > Perhaps I can redeem myself for my ?asshattery? by providing some
                                          > solutions.
                                          > Here are three Parent scripts that will pause the play head.
                                          >
                                          > 1. By exploiting a side effect of using timeout objects, an ?exitFrame?
                                          > method can be added to a global script object and you can turn on or off
                                          > whether the exitframe method is called or not.
                                          >
                                          > Usage:
                                          > gPlayHead = script(?Playhead Pause?).new()
                                          > gPlayHead.pause()
                                          > gPlayHead.continue()
                                          >
                                          >
                                          > -- Playhead pause
                                          >
                                          > property pTimeOb
                                          >
                                          > on new me
                                          > return me
                                          > end
                                          >
                                          > on pause me
                                          > pTimeOb = timeout().new("pause_"&me, 0, #update, me)
                                          > end
                                          >
                                          > on continue me
                                          > if pTimeOb.objectP then
                                          > pTimeOb.forget()
                                          > pTimeOb = 0
                                          > end if
                                          > end
                                          >
                                          > on exitframe me
                                          > go the frame
                                          > end
                                          > --------------------------------------------
                                          >
                                          > 2. Dynamically create a Movie script with an exitFrame-go-the-frame
                                          > function.
                                          >
                                          > Usage:
                                          > gPlayHead = script(?Playhead Pause?).new()
                                          > gPlayHead.pause()
                                          > gPlayHead.continue()
                                          >
                                          > -- Playhead Pause
                                          >
                                          > property pLoopScript
                                          >
                                          > on new me
                                          > return me
                                          > end
                                          >
                                          > on pause me
                                          > pLoopScript = new(#script)
                                          > pLoopScript.scriptType = #Movie
                                          > Code = "on exitframe " & Return & "go the frame" & Return & "end"
                                          > pLoopScript.scriptText = Code
                                          > end
                                          >
                                          > on continue me
                                          > pLoopScript.erase()
                                          > pLoopScript = void
                                          > end
                                          > --------------------------------------------------------------
                                          >
                                          > 3. If your Message Object places one or more sprites on the stage then
                                          > you
                                          > can provide the appropriate interface and add the object to the sprite's
                                          > scriptInstanceList.
                                          >
                                          > Usage:
                                          > gMessage = script("Message").new()
                                          > gMessage.show()
                                          >
                                          > -- message
                                          >
                                          > property pMessageSprite
                                          >
                                          > on new me
                                          > return me
                                          > end new
                                          >
                                          > on show me
                                          > TextMem = new(#Text)
                                          > TextMem.text = "Click To Close."
                                          > TextMem.width = 150
                                          >
                                          > pMessageSprite = sprite(1)
                                          > pMessageSprite.puppet = true
                                          > pMessageSprite.member = TextMem
                                          > pMessageSprite.loc = point(200,100)
                                          > pMessageSprite.scriptInstancelist.add(me)
                                          > end
                                          >
                                          > on mouseUp me
                                          > pMessageSprite.member.erase()
                                          > pMessageSprite.puppet = false
                                          > end
                                          >
                                          > on exitFrame me
                                          > go the frame
                                          > end
                                          >