3 Replies Latest reply on Sep 20, 2007 1:07 PM by McFazstp

    film loop control

    Level 7
      Have a few film loop questions:

      1) Is it possible to pause a film loop - if so, how?
      2) Is it possible to test what frame of the film loop you're in?
      3) Is it possible to test when the film loop has finished a full loop?

      Thanks.

        • 1. Re: film loop control
          Level 7
          Film loops are effectively "dumb" Linked Director Movies

          > 1) Is it possible to pause a film loop - if so, how?

          Yes. To communicate with film loops you use "tell sprite(x) to ..."
          In the case of pausing I think you tell it to go to the frame - 1

          > 2) Is it possible to test what frame of the film loop you're in?

          tell sprite x to f = the frame

          > 3) Is it possible to test when the film loop has finished a full loop?

          You'll have to try a few things. I think the last frame is frameCount or
          perhaps 'last frame'. You'll have to monitor the loop to determine when
          it hits its last frame
          • 2. film loop control
            knew-bee Level 1
            I got fed up with film loops' limitations, so I made my own Custom Film Loop Parent Script. You might find it useful.


            -- Start Custom Film Loop Class --

            property pFrameList
            property pTotalFrames
            property pCurrentFrame
            property pFrameIteration
            property pAnimating
            property pLoop
            property pStartFrame
            property pEndFrame
            property pMySpriteNum


            -- constructor: frameList should be a list containing property lists formatted as follows:
            -- [#frameImage:member("testImage1"), #frameSpan:1], [#frameImage:member("testImage2"), #frameSpan:5]]
            on new(me, frameList)
            pFrameList = frameList
            pTotalFrames = pFrameList.count
            pCurrentFrame = 1
            pFrameIteration = 0
            pAnimating = FALSE
            pLoop = TRUE
            pStartFrame = 1
            pEndFrame = pTotalFrames
            pMySpriteNum = -1
            return me
            end

            -- call updateMe() in an exitFrame or enterFrame handler
            on updateMe(me)
            if pMySpriteNum > 0 then
            if pAnimating = TRUE then
            iterateCount(me)
            else
            end if
            end if
            end

            -- Private
            on iterateCount(me)
            currentFrameCount = pFrameList[pCurrentFrame][#frameSpan]
            pFrameIteration = pFrameIteration + 1
            if pFrameIteration > currentFrameCount then
            if pCurrentFrame = pEndFrame and not pLoop then
            pAnimating = FALSE
            else
            moveFrame(me, 1)
            end if
            end if
            end

            -- moveFrames args: frames:uint = number of frames to advance
            on moveFrame(me, frames)
            diff = pEndFrame - pStartFrame + 1
            tempFrame = pCurrentFrame - pStartFrame
            tempFrame = (tempFrame+frames)mod diff
            setFrame(me, tempFrame + pStartFrame, pAnimating)
            pFrameIteration = 0
            end

            -- Private
            on displayFrame(me)
            if pMySpriteNum > 0 then
            sprite(pMySpriteNum).member = pFrameList[pCurrentFrame][#frameImage]
            else
            if _system.environmentPropList[#runmode] = "Author" then
            alert("AnimationClass : displayFrame : no sprite selected")
            end if
            end if
            end


            -- setFrame args: frameNum:int = which frame to set to, run:bool = continue playing from frame
            on setFrame(me, frameNum, run)
            if frameNum <= pTotalFrames then
            pCurrentFrame = frameNum
            pAnimating = run
            displayFrame(me)
            else
            if _system.environmentPropList[#runmode] = "Author" then
            alert("AnimationClass : setFrame : frameNum arg out of range")
            end if
            end if
            end

            on getFrame(me)
            return pCurrentFrame
            end

            -- setSprite args: theSprite:uint = the spriteNum to set the animation to
            -- make sure setSprite is called before setAnimating(true) or nothing will show
            -- setSprite does not puppet a sprite channel, theSprite should refer to an already set sprite or a puppeted channel
            on setSprite(me, theSprite)
            pMySpriteNum = theSprite
            end

            on getSprite(me)
            return sprite(pMySpriteNum)
            end

            -- setAnimating args: animating:bool = true to run animation, false to stop on frame
            -- make sure setSprite is called before setAnimating(true) or nothing will show
            on setAnimating(me, animating)
            pAnimating = animating
            end

            on getAnimating(me)
            return pAnimating
            end

            -- setLoop args: looping:bool = true to loop animation, false to stop on end frame
            on setLoop(me, looping)
            pLoop = looping
            end

            -- setStartFrame args: theFrame:uint = frame you want the animation to start from when a loop is completed
            on setStartFrame(me, theFrame)
            if theFrame < pEndFrame then
            pStartFrame = theFrame
            if pCurrentFrame < pStartFrame then
            setFrame(me, pStartFrame, pAnimating)
            end if
            else
            if _system.environmentPropList[#runmode] = "Author" then
            alert("AnimationClass : setStartFrame : start frame > end frame")
            end if
            end if

            end

            on getStartFrame(me)
            return pStartFrame
            end

            -- setStartFrame args: theFrame:uint = frame you want the animation to start from when a loop is completed
            on setEndFrame(me, theFrame)
            if theFrame > pStartFrame then
            pEndFrame = theFrame
            if pCurrentFrame > pEndFrame then
            setFrame(me, pEndFrame, pAnimating)
            end if
            else
            if _system.environmentPropList[#runmode] = "Author" then
            alert("AnimationClass : setStartFrame : end frame < start frame")
            end if
            end if
            end

            on getEndFrame me
            return pEndFrame
            end

            -- Private. use setAnimating(true) to start the animation from the current frame
            on startAnimation(me)
            pAnimating = TRUE
            end

            -- Private. use setAnimating(false) to stop the animation on the current frame
            on stopAnimation(me)
            pAnimating = FALSE
            end

            -- End Custom Film Loop Class --

            • 3. Re: film loop control
              McFazstp
              film_loop = sprite( x ).movie

              if ( film_loop.frame = film_loop.lastFrame ) then
              film_loop.go( film_loop.lastFrame )
              end if