8 Replies Latest reply on Jul 1, 2007 9:17 PM by Newsgroup_User

    sprite blend

    Blindgator
      I am trying to get my sprites become more transparent when a button is clicked. How do i do that?

      Thanks
        • 1. Re: sprite blend
          Level 7
          When you say "more" transparent, perhaps you mean something like:
          -- attached to button sprite
          on mouseUp me
          _movie.sendAllSprites(#mBlendMore, 10)
          end

          -- attached to sprites you want to blend:
          on mBlendMore me, amount
          sprite(me.spriteNum).blend = max(0, sprite(me.spriteNum).blend - amount)
          end
          • 2. Re: sprite blend
            Blindgator Level 1
            I tried that but this is what I got.... script error operator expected _movie.?sendAllSprites(#mBlendMore, 10)

            This is my script
            global gcHand
            global gH3
            global gH2
            global gH1
            global gmyhand3
            global gmyhand2
            global gmyhand1
            on mouseup me
            if gcHand = 3 then
            set gH3 = 0
            set gcHand = 2
            set the visible of sprite 46 = 0
            go to frame 150
            put gmyhand3 into member "mytotalthree"
            _movie.sendAllSprites(#mBlendMore, 10) ---------
            end
            else if gcHand = 2 then
            .....

            and then attacted to the sprite I have
            on mBlendMore me, amount
            sprite(me.spriteNum).blend = max(0, sprite(me.spriteNum).blend - amount)
            end

            I am pretty new to Director and have no idea what I am doing wrong here and any help would be greatly apreciated.
            Thanks
            Brian
            • 3. Re: sprite blend
              Level 7
              Hi Brian,

              Your behavior does look overly complicated. I'm sure it could be written in a
              simpler way.

              Can you describe eaxctly what you want to do. For example are you clicking
              sprite 10 and then sprites 15 to 20 become semi-transparent? If so, you could
              just attach the following to sprite 10:
              on mouseUp
              repeat with x = 15 to 20
              sprite(x).blend = sprite(x).blend - 10
              end repeat
              end

              This is actually a hard coded version of what Sean described. He gave 2
              behaviors. The first
              on mouseUp me
              _movie.sendAllSprites(#mBlendMore, 10)
              end
              tells how much blend to drop by, in this case 10%.

              The second behavior
              on mBlendMore me, amount
              sprite(me.spriteNum).blend = max(0, sprite(me.spriteNum).blend - amount)
              end
              is attched to sprites that will blend out. This behavior receives a message from
              the first. The sendAllSprites bit send data to other sprites' behaviors. It may
              be confusing if you've never heard of this before.

              By using Sean's, you can move the sprites around the Score and it won't make a
              difefrence. With mine, since it's linked to specific channels, you have to match
              the script with the Score.

              I have technotes on Lingo at:
              Programming Definitions -
              http://www.fbe.unsw.edu.au/learning/director/Lingo/definitions.asp
              Using sendSprite -
              http://www.fbe.unsw.edu.au/learning/director/Lingo/sendSprite.asp
              Look at my tutorials page for the full list:
              http://www.fbe.unsw.edu.au/learning/director/

              Now, I see you're using verbose syntax. Sean and my example use dot sytax.
              Verbose syntax - set property to value
              eg
              set the visible of sprite 2 to TRUE
              (TRUE = 1, FALSE = 0)

              Dot Syntax - object.property = value
              eg
              sprite(2).visible = 1

              By the way, the visible property affects the entire sprite channel. So, if you
              set sprite 2's visiblity to 0 in frame 1, it will be invisible through the
              entire Score. So, developers that need a sprite to be invisible may either move
              it off stage or set the blend to 0, setting it off stage is probably better.

              Some other advice for you.
              * you don't need to use 'set' anymore.
              gH3 = 0
              will work fine without the 'set' at the start
              * Don't write 'go to frame 150'
              Linking to a specific frame number is asking for trouble. You may insert frames
              or delete frames while creating uour movie and then bugs appear in scripts like
              this. Instead, create markers (frame labels) in your Score and use:
              go to "MarkerName"

              * Don't use - put gmyhand3 into member "mytotalthree"
              It's very old Lingo. If you want to the value of gmyhand3 in your text member
              use:
              set the text of member "mytotalthree" to string(gmyhand3)
              or
              member(""mytotalthree").text = string(gmyhand3)

              Anyway, give more info on what you're doing and we'll guide you to achieve the
              best possible result.

              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


              • 4. Re: sprite blend
                Blindgator Level 1
                Thanks Dean for all your help with my scripting, it has really simplified my program. The goal i am trying to achieve with this blendmore is to emphasize differant cards(sprites) by making the other cards become transparent when a player moves on to his next hand. I got the
                repeat with x = 15 to 20
                sprite(x).blend = sprite(x).blend - 10
                end repeat

                to work fine for what I needed, but ideally I would like to have a handler that i could just attach to ever sprite that needed it. I cut all the extra stuff of out my scripts and tried what Sean first told me...

                on mouseUp me
                _movie.sendAllSprites(#mBlendMore, 10)
                end --- I attached this to the sprite that is clicked on.

                on mBlendMore me, amount
                sprite(me.spriteNum).blend = max(0, sprite(me.spriteNum).blend - amount)
                end --- I have this attacted to the sprites I want

                but I still came up with an error when I compiled the script that said

                script error operator expected _movie.?sendAllSprites(#mBlendMore, 10)

                I am not very familiar with programming like this, is there something really obvious that Im just not defining here or what could be wrong?


                Thanks again.

                • 5. Re: sprite blend
                  Level 7
                  Blindgator wrote:

                  > but I still came up with an error when I compiled the script that said
                  >
                  > script error operator expected _movie.?sendAllSprites(#mBlendMore, 10)
                  >
                  > I am not very familiar with programming like this, is there something really
                  > obvious that Im just not defining here or what could be wrong?

                  Hi Brian,

                  I just tried the script and did not get any errors. If you'd like to email me
                  directly, I can email you the demo file I created with the scripts working or you
                  could email me yours and I can look at why it's not working.

                  Let me explain the statements from each script:
                  _movie.sendAllSprites(#mBlendMore, 10)
                  this says send the custom message 'mBlendMore' to all sprites in the frame and
                  include a parameter of 10.

                  on mBlendMore me, amount
                  when the 'mBlendMore' message is sent from the 'sendAllSprites' statement, this
                  is activated. 'me' is the default first parameter, amount will become = 10

                  sprite(me.spriteNum).blend = max(0, sprite(me.spriteNum).blend - amount)
                  Here we use me by saying 'me.SpriteNum' to represent the sprite that this
                  behavior is attached to. The blend of this sprite os set to
                  max(0, sprite(me.spriteNum).blend - amount)
                  By using max( ), we're saying, choose the highest value of the items in the
                  brackets. max(1, 3) would = 3. We have this to prevent the blend going into the
                  negative.
                  'sprite(me.spriteNum).blend - amount' is the current blend - the 10% amount.

                  That's an explanation of the code. As to why it's not working for you, I can only
                  guess. Could be a typo. But, as I said, if you'd like to email me, I can send you
                  a working demo.

                  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


                  • 6. Re: sprite blend
                    Level 7

                    Brian,

                    Another thought why it may not be working, what version of Director are you
                    using? The '_movie' was introduced in Director MX 2004. If you're using an
                    earlier version, you could use
                    sendAllSprites (#mBlendMore, 10)
                    This will also work with MX 2004. Let me know if this fixes the issue.

                    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

                    • 7. Re: sprite blend
                      Blindgator Level 1
                      Well the sendAllSprites (#mBlendMore, 10) worked and I figured out I have Director MX version 9.0 which I dont know if it is considered 2004 but I couldnt get the other way to work. So I assume I dont have 2004. Thanks for all your time and help.


                      Brian
                      • 8. Re: sprite blend
                        Level 7
                        Blindgator wrote:

                        > Well the sendAllSprites (#mBlendMore, 10) worked and I figured out I have
                        > Director MX version 9.0 which I dont know if it is considered 2004 but I
                        > couldnt get the other way to work. So I assume I dont have 2004. Thanks for all
                        > your time and help.

                        Hi Brian,

                        Director MX is the version behind MX 2004. So, the issue was that you were using
                        new Lingo that was in the later version. Adobe have announced that the next evrsion
                        will be called Director 11, so will be a better naming system.

                        Anyway, wish you all the best with your Director endevours. Hope my tutorials are
                        helpful. If you have any questions, feel free to email me.

                        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