6 Replies Latest reply on Jan 8, 2007 6:45 AM by Newsgroup_User

    Changing the cast member of a sprite

    pete_484
      Hi, I have the following code so that when a user clicks on a shape (acting as a button), it changes the cast member of an existing sprite called "base" on the stage to an image cast member called "Italian Lira". However the code does not work, any suggestions what I have done wrong?

      on mouseUp me
      currency = "Italian Lira"

      sprite("base").member = member(currency)
      end
        • 1. Re: Changing the cast member of a sprite
          Level 7
          first try changing "base" to the sprite number. I've heard that naming
          sprites doesn't work properly in Director

          Is "base" a cast member rather than a sprite?


          • 2. Re: Changing the cast member of a sprite
            Level 7
            You can't use a name for a sprite. It has to be a number, or a relative
            reference like this:

            on mouseUp me
            currency = "Italian Lira"
            sprite(the currentSpriteNum).member = member(currency)
            end
            • 3. Re: Changing the cast member of a sprite
              Level 7
              Didn't MM implement sprite names in MX 2004?


              --
              Craig Wollman
              Lingo Specialist
              Word of Mouth Productions
              212-928-9581

              www.wordofmouthpros.com
              "Word One - Denver" <wordonedenver@comcast.net> wrote in message
              news:ensn1i$1k3$2@forums.macromedia.com...
              > You can't use a name for a sprite. It has to be a number, or a relative
              > reference like this:
              >
              > on mouseUp me
              > currency = "Italian Lira"
              > sprite(the currentSpriteNum).member = member(currency)
              > end


              • 4. Re: Changing the cast member of a sprite
                Level 7
                Yes they did. I am not sure why so many people are saying not to do it,
                because I name sprites in practically every project I do these days.
                Assuming that you sprite is named correctly, this should work (I just
                removed the word member in the 2nd line):

                on mouseUp me
                currency = "Italian Lira"
                sprite("base").member = currency
                end
                • 5. Re: Changing the cast member of a sprite
                  Level 7
                  Cool. Didn't know that. I've got MX 2004, but I still use my 8.5.1
                  version 99% of the time because I have some xtras I like that don't work
                  with MX.
                  • 6. Re: Changing the cast member of a sprite
                    Level 7
                    Thanks for keeping me sane Mike. I've always used a global list with sprite
                    assignments so I never had to deal with whether or not the sprite names
                    feature worked. But I guess you've dispelled the myth. Thanks.

                    I guess we still don't know whether "base" is a sprite name or mistakenly
                    and cast member name. I see that we haven't heard back from pete_484 on
                    this.


                    --
                    Craig Wollman
                    Lingo Specialist
                    Word of Mouth Productions
                    212-928-9581

                    www.wordofmouthpros.com
                    "Mike Blaustein" <mblaustein@gmail.com> wrote in message
                    news:enthgu$22c$1@forums.macromedia.com...
                    > Yes they did. I am not sure why so many people are saying not to do it,
                    > because I name sprites in practically every project I do these days.
                    > Assuming that you sprite is named correctly, this should work (I just
                    > removed the word member in the 2nd line):
                    >
                    > on mouseUp me
                    > currency = "Italian Lira"
                    > sprite("base").member = currency
                    > end