7 Replies Latest reply on Aug 7, 2006 2:46 PM by Newsgroup_User

    Wishlist idea - Named channels

    Level 7
      One major thing that's always been a real annoyance to me in this program -
      If you ever refer to sprite channels by number in your code, and then later
      on you find you need to move everything down by one channel to make room for
      something higher up - you have to go through and fix all your code to make
      it work again. I have an easy solution to this. Named channels. You can
      name a frame, via Frame Markers. Why not have the same functionality on the
      channels? Allow channels to be re-ordered on the fly, and have them keep
      their name as a fixed property of that channel, regardless of its position
      in the score. You could then refer to your channels by a name that makes
      sense, rather than an arbitrary number based on its order in the score. And
      thus you could move your channels around all you want without having to
      worry about rewriting your code. All in all, there's no reason not to do
      it. It just makes sense on so many levels.

      I've sort of been doing this on my own in some projects, by having a set of
      globals that give the channels of certain sprites that get referenced a lot,
      so instead of having to change all my code when things get moved, I only
      need to change that one declaration at the beginning. But this is still
      somewhat cumbersome, in that the global values have to be declared in every
      function that uses them, and I'm sure it's wasteful of memory keeping all
      that information available. Having that feature available in the program
      would make life so much easier. Who's with me on this one?


        • 1. Re: Wishlist idea - Named channels
          Level 7
          On Mon, 07 Aug 2006 19:55:55 GMT, Darrel Hoffman posted in
          macromedia.director.lingo:

          > You can name a frame, via Frame Markers. Why not have the same
          > functionality on the channels?

          Hi Darrel,

          If you're using Dir MX 2004 (I'm not), your wish has already been granted.
          You can name the channels and/or individual sprites:

          (beware of word wrap)

          name (Sprite Channel)
          http://livedocs.macromedia.com/director/mx2004/release_update_en/09_pr417.h
          tm#202952

          name (Sprite)
          http://livedocs.macromedia.com/director/mx2004/release_update_en/09_pr416.h
          tm#202933


          --
          Mark A. Boyd
          Keep-On-Learnin' :)
          • 2. Re: Wishlist idea - Named channels
            Level 7
            > I've sort of been doing this on my own in some projects, by having a set
            of
            > globals that give the channels of certain sprites that get referenced a
            lot,
            > so instead of having to change all my code when things get moved, I only
            > need to change that one declaration at the beginning.

            If you use a beginSprite handler to set the global, you shouldn't ever have
            to change any code. I also tend to use a property list to store multiple
            globals. For example:

            global g
            property spriteNum

            on beginSprite me
            g[#someSpecialSpriteChannel] = spriteNum
            end

            Now you can reference the sprite by the g[#someSpecialSpriteChannel]. Very
            similar to what I think you are doing, except it's not hard coding the
            channel number. As Mark mentioned, the latest version does support
            channeling naming.


            • 3. Re: Wishlist idea - Named channels
              Level 7
              > If you're using Dir MX 2004 (I'm not), your wish has already been granted.
              > You can name the channels and/or individual sprites:

              D'oh. Go figure, I'm one version behind, and that's the version that fixes
              exactly what I asked for. Just occurred to me since this feature's been
              pretty much the same ever since Director 1 that it didn't look like they
              were going to change it any time soon. Guess I was wrong.


              • 4. Re: Wishlist idea - Named channels
                Level 7
                > If you use a beginSprite handler to set the global, you shouldn't ever
                have
                > to change any code. I also tend to use a property list to store multiple
                > globals. For example:
                >
                > global g
                > property spriteNum
                >
                > on beginSprite me
                > g[#someSpecialSpriteChannel] = spriteNum
                > end
                >
                > Now you can reference the sprite by the g[#someSpecialSpriteChannel]. Very
                > similar to what I think you are doing, except it's not hard coding the
                > channel number. As Mark mentioned, the latest version does support
                > channeling naming.

                This doesn't work. Maybe I'm missing something, but do you need to set up
                'g' at the beginning to already have those properties in the list? When I
                did a:

                global g
                on startMovie
                g[#someSpecialSpriteChannel:0]
                end

                And then let the code you supplied run on the individual sprite, it worked,
                but if I have to set up every property in the startMovie, it's no better
                than my pile of globals. Then I removed that code again, and it still
                worked, but only because Director still had that list in its residual
                memory. Create a projector, and it doesn't work anymore. I tried declaring
                'g' as an empty property list, "g = [:]", but that just resulted in other
                errors. I think there's one more step I'm missing here...


                • 5. Re: Wishlist idea - Named channels
                  Level 7
                  No, you do not have to declare every property. You need only declare then
                  varible as a property list. I usually do this in a prepareMovie handler.

                  global g
                  on prepareMovie
                  g = [:]
                  end

                  Now you can create properties anywhere.

                  "Darrel Hoffman" <no.address@all.com> wrote in message
                  news:eb8a6i$q2e$1@forums.macromedia.com...
                  > > If you use a beginSprite handler to set the global, you shouldn't ever
                  > have
                  > > to change any code. I also tend to use a property list to store multiple
                  > > globals. For example:
                  > >
                  > > global g
                  > > property spriteNum
                  > >
                  > > on beginSprite me
                  > > g[#someSpecialSpriteChannel] = spriteNum
                  > > end
                  > >
                  > > Now you can reference the sprite by the g[#someSpecialSpriteChannel].
                  Very
                  > > similar to what I think you are doing, except it's not hard coding the
                  > > channel number. As Mark mentioned, the latest version does support
                  > > channeling naming.
                  >
                  > This doesn't work. Maybe I'm missing something, but do you need to set up
                  > 'g' at the beginning to already have those properties in the list? When I
                  > did a:
                  >
                  > global g
                  > on startMovie
                  > g[#someSpecialSpriteChannel:0]
                  > end
                  >
                  > And then let the code you supplied run on the individual sprite, it
                  worked,
                  > but if I have to set up every property in the startMovie, it's no better
                  > than my pile of globals. Then I removed that code again, and it still
                  > worked, but only because Director still had that list in its residual
                  > memory. Create a projector, and it doesn't work anymore. I tried
                  declaring
                  > 'g' as an empty property list, "g = [:]", but that just resulted in other
                  > errors. I think there's one more step I'm missing here...
                  >
                  >


                  • 6. Re: Wishlist idea - Named channels
                    Level 7
                    > No, you do not have to declare every property. You need only declare then
                    > varible as a property list. I usually do this in a prepareMovie handler.
                    >
                    > global g
                    > on prepareMovie
                    > g = [:]
                    > end
                    >
                    > Now you can create properties anywhere.

                    Ah... Maybe it's because I used "startMovie" instead of "prepareMovie"?
                    (Otherwise, that code is identical to what I did.) Let's see... Yeah, that
                    was it. I suspect my beginSprite code was running before the startMovie
                    code, or something, and thus g didn't exist yet. Thanks. This might come
                    in handy.


                    • 7. Re: Wishlist idea - Named channels
                      Level 7
                      Sorry, I should have mentioned that in my first response. Not that this will
                      save you tones of work, but every little bit helps I suppose.