8 Replies Latest reply on Jan 5, 2008 4:50 AM by Newsgroup_User

    Behavior shortcuts?!

    BigDaddy
      Hi

      I have a script where I have to compute the SAME lines OVER and OVER...
      It's killing me- the number of lines/time to update/change them.

      Is there a way to...
      Name an action AND call for it later?

      This will help me to build my knowledge base.

      Thanks
      BigDaddy
        • 1. Re: Behavior shortcuts?!
          Level 7

          "BigDaddy" <webforumsuser@macromedia.com> wrote in message
          news:flk6me$rk7$1@forums.macromedia.com...
          > Hi
          >
          > I have a script where I have to compute the SAME lines OVER and
          > OVER...
          > It's killing me- the number of lines/time to update/change them.
          >
          > Is there a way to...
          > Name an action AND call for it later?
          >
          > This will help me to build my knowledge base.
          >
          > Thanks
          > BigDaddy
          >

          You mean define it as a "function" ?
          If so, then just make a handler that has the code, and call that. With
          specific parameters if needed.
          I can give examples, but thats endless.

          Can you show a bit of what you have and what you are trying to do?

          Richard.


          • 2. Re: Behavior shortcuts?!
            Level 7
            This sort of thing is usually simplified by using repeat loops and
            possible some sort of list. If you will post some specifics about what
            you are doing, more detailed help can be provided.


            BigDaddy wrote:
            > Hi
            >
            > I have a script where I have to compute the SAME lines OVER and OVER...
            > It's killing me- the number of lines/time to update/change them.
            >
            > Is there a way to...
            > Name an action AND call for it later?
            >
            > This will help me to build my knowledge base.
            >
            > Thanks
            > BigDaddy
            >
            • 3. Re: Behavior shortcuts?!
              BigDaddy Level 1
              Hi

              Something like this...

              if x > y and y >= z then
              sprite(p).rect = rect...
              sprite(q).rect = rect...
              sprite(r).rect = rect...
              sprite(p).member = ...
              sprite(q).member = ...
              sprite(r).member = ...

              else
              ...

              Then I have other conditionals when if met then other changes.
              All of the lines are driving me crazy.
              If I could consolidate the actions after each conditional- I'd love that.

              Thanks
              BigDaddy
              • 4. Re: Behavior shortcuts?!
                Level 7
                > Something like this...
                >
                > if x > y and y >= z then
                > sprite(p).rect = rect...
                > sprite(q).rect = rect...
                > sprite(r).rect = rect...
                > sprite(p).member = ...
                > sprite(q).member = ...
                > sprite(r).member = ...

                How about: (untested)

                repeat with i in [p,q,r]
                sprite(i).rect = rect...
                sprite(i).member = rect...
                end repeat

                I'm pretty sure that'll work, not sure how much this helps you though...


                • 5. Re: Behavior shortcuts?!
                  Level 7
                  > repeat with i in [p,q,r]
                  > sprite(i).rect = rect...
                  > sprite(i).member = rect...
                  > end repeat

                  Uhh... Disregard the "rect" in the "member" line, of course. Oops.


                  • 6. Re: Behavior shortcuts?!
                    BigDaddy Level 1
                    Hi

                    I am already utilizing 'repeats'. I need to see if I can establish 'something' to equal all of the lines-
                    so that I can just say 'abracadabra'- and all of those other lines will execute.

                    Thanks for responding.
                    BigDaddy
                    • 7. Re: Behavior shortcuts?!
                      Level 7

                      "BigDaddy" <webforumsuser@macromedia.com> wrote in message
                      news:flm18v$sqh$1@forums.macromedia.com...
                      > Hi
                      >
                      > Something like this...
                      >
                      > if x > y and y >= z then
                      > sprite(p).rect = rect...
                      > sprite(q).rect = rect...
                      > sprite(r).rect = rect...
                      > sprite(p).member = ...
                      > sprite(q).member = ...
                      > sprite(r).member = ...
                      >
                      > else
                      > ...
                      >
                      > Then I have other conditionals when if met then other changes.
                      > All of the lines are driving me crazy.
                      > If I could consolidate the actions after each conditional- I'd love
                      > that.
                      >
                      > Thanks
                      > BigDaddy
                      >
                      >

                      Hi again,
                      is the part between the IF and ELSE always the same (except for the
                      values you set of course)?

                      If so, you can do something like this (assuming you use this in a
                      behaviour):

                      if x > y and y >= z then
                      a = ...
                      b = ...
                      c = ...
                      d = ...
                      e = ...
                      f = ...

                      me.setValues (a,b,c,d,e,f)
                      else
                      -- Or a shorter version (but less readable) is to call like this:
                      me.setValues ( rect(1,1,2,2), rect(1,1,2,2), rect(1,1,2,2), d, e,
                      f )
                      endif


                      -- Handler in the same behaviour:
                      on setValues me, this_a, this_b, this_c, this_d, this_e, this_f

                      sprite(p).rect = this_a
                      sprite(q).rect = this_b
                      sprite(r).rect = this_c
                      sprite(p).member = this_d
                      sprite(q).member = this_e
                      sprite(r).member = this_f

                      end setValues

                      Does that help?

                      Richard.


                      • 8. Re: Behavior shortcuts?!
                        Level 7
                        BigDaddy wrote:

                        > Hi
                        >
                        > I am already utilizing 'repeats'. I need to see if I can establish
                        > 'something' to equal all of the lines-
                        > so that I can just say 'abracadabra'- and all of those other lines will
                        > execute.

                        Would custom handlers be what you need? Here's how they work.
                        In a movie script have:
                        on abracadabra
                        -- statement 1
                        -- statement 2
                        -- statement 3
                        end

                        Then in a behavior, you can just use 'abracadabra' and it will execute all
                        the lines in the movie script's abracadabra handler. I have an example of a
                        custom hanndler, with parameters at:
                        http://www.fbe.unsw.edu.au/learning/director/Lingo/parameters.asp

                        Hope that helps.

                        regards
                        Dean

                        Director Lecturer / Consultant / Director Enthusiast
                        http://www.fbe.unsw.edu.au/learning/director
                        http://www.multimediacreative.com.au
                        email: d.utian@unsw.edu.au