5 Replies Latest reply on Dec 6, 2009 10:50 PM by TJD47

    Wait for the end of Flash Animation

    TJD47

      I have been using a behavior to "wait for the end of the Flash animation" before jumping to the next frame for about 8 years. I am now updating the project for Director 11.5. The code no longer seems to work in this new version of Director. Can anyone give me a simple way to achieve this? I have been searching the forums and even online for answers, but have found none. I would very much appreciate any help with this and thank you very much in advance.

        • 1. Re: Wait for the end of Flash Animation
          Chunick Level 3

          would it be possible to post the code you were using before?... maybe it just needs a bit of modification. Btw, what version of Director were you using prior to D11.5?

          • 2. Re: Wait for the end of Flash Animation
            TJD47 Level 1

            Thanks for your help with this, Joshua. Below is code that I now found that does work in Director 11.5, but must it be placed into the script channel and each Flash sprite channel must then be specified. The code I used in Director MX 2004 and before was placed directly onto the sprite and the correct sprite channel was automatically set. I know this difference seems minor, but I am using an external cast and so that all Flash sprites in my project are affected (the project is large). Is there a way to modify this code to allow it to be placed onto a Flash sprite where the correct channel is automatically set?


            property flashSprite
            property flashFrameCount
            property bEnabled

            on isOKToAttach me, sType, sNum
              return (sType = #script)
            end

            on getPropertyDescriptionList
              lRange = []
              repeat with c = 1 to the lastChannel
                if sprite(c).member.type = #flash then lRange.append(c)
              end repeat
              pdl = [:]
              pdl[#flashSprite] = [#comment: "Flash sprite channel:", #format: #integer, #default: 0, #range: lRange]
              return pdl
            end

            on beginSprite me
              bEnabled    = 1
              flashSprite = sprite(flashSprite)
              tMember     = flashSprite.member
              if tMember.type <> #flash then
                bEnabled = 0
                exit
              end if
              flashFrameCount = tMember.frameCount
            end

            on exitFrame me
              if bEnabled then
                if (flashSprite.frame = flashFrameCount) then
                  tFrame = _movie.frame + 1
                else
                  tFrame = _movie.frame
                end if
                _movie.go(tFrame)
              end if
            end

            • 3. Re: Wait for the end of Flash Animation
              Sean_Wilson Adobe Community Professional

              The code you posted looks familiar

               

              There's no way you would have been able to attach it directly to a Flash sprite - the #isOKToAttach handler expressly forbids this. You must have been using a different behavior/script.  It can be modified to work directly with the sprite:

              property spriteNum
              property my
              property flashFrameCount
              property bEnabled
              
              on isOKToAttach me, sType, sNum
                if (sType = #graphic) then return (sprite(sNum).member.type = #flash)
                return 0
              end
              
              on beginSprite me
                bEnabled = 1
                my       = sprite(spriteNum)
                tMember  = my.member
                if tMember.type <> #flash then
                  bEnabled = 0
                  exit
                end if
                flashFrameCount = tMember.frameCount
              end
              
              on exitFrame me
                if bEnabled then
                  if (my.frame = flashFrameCount) then
                    tFrame = _movie.frame + 1
                  else
                    tFrame = _movie.frame
                  end if
                  _movie.go(tFrame)
                end if
              end
              
              • 4. Re: Wait for the end of Flash Animation
                TJD47 Level 1

                Thanks for your help with this, Sean. Your code works perfectly and exactly replaces the previous code. I obtained my previously posted code from the Director-Online forum or some similar discussion group. If this was your code, it was not idenfied as such, so I thank you. And, you are correct that this was not the old code that I have been using for years (which, to be honest, I could not understand at all - although is did work well before Director 11.5), but was a new attempt at a solution.

                 

                As a side note, as I searched the web for solutions, I could not help but notice the tremendous decrease in new Director-related information throughout the web, including discussion posting. This is a very sad note, IMO, and I sure hope Adobe has a good plan for a turn-around (Director 12?). Director remains my program of choice for multimedia work.

                • 5. Re: Wait for the end of Flash Animation
                  TJD47 Level 1

                  Upon further use of your new code, I have discovered one minor difference from the old code that I used in Director MX 2004. In both, the Flash animation plays fully at frame one of a stretched out sprite. But, with the new code, any "go to the frame" in any frames where the entire Flash sprite resides, is ignored (even after the animation has played out). A minor and workable point (I have already found a workaround by splitting the sprite). But, there are times when I want the Flash animation to play and then have that last visual stay on the screen by using a "go to the frame" stop (this is how the old code worked). I cannot achieve this without splitting the sprite and then somehow that magically works (it seems to me that it should replay the entire Flash animation from the beginning, but it does not). Anyhow, Sean thanks again and thanks for all your wonderful support on this forum. I read it regularly.