Simon Wheatley wrote:

> Is there any way of addressing filmloops with lingo and getting them to
> play, stop, set the loop property etc?

<very long sig snipped>

Okay now that everyone has beat up on Simon for his lengthy sig... here is a possible 
solution. First off lets say that filmloops are extremely finicky and although this 
will work, more or less, I'd recommend going with linked director movies (LDMs) since 
they are truly autonomous or using flash for embedded movies. If you want we can 
discuss the merits of all these possibilities but for now
here is your filmloop answer.

Create your filmloop as usual then put the following behaviour on it (watch out for 
incorrectly wrapped lines due to e-mail):

property pLoopDirection, pLoopStatus, pCurrentFrame

on beginSprite me
  pCurrentFrame=1
end

on enterFrame me
  --can't use exitFrame to tell a sprite to changes its frame position because it will 
lock the stage
  --basically if you tell a loop to go to frame 2 it will go to frame 3 so we 
ultimately need to subtract 1 from where we think the frame should be
  --that is why there is a property to track current expected postion

  --so a loop starts on frame 1, if you try to pause it right away by telling it so go 
to frame 1 the loop will actually advance to frame 2 and hold there
  --so if you want it at frame 1 then you need to tell it to go to frame 0, this of 
course does not work, the 0 is ignored and the loop advances to frame 2 then pauses
  --but if you have the loop member set to loop and then tell is to go to the last 
frame of the loop it of course will advance to frame 1 and pause there
  --basically that is what the case stuff below is doing, adjusting for this offset.

  --this all works beautifully unless you hit update stage or use something like 
directors scrolling text or button members which force a stage update
  --when the update occurs the loop knows that it really isn't paused at frame 1, but 
rather at the last frame so it redraws the last frame then advances
  --to the pause frame of 1 and redraws it so you get a flash on the screen. What a 
pain.

  --Also note the by using a behavior property to determine if the movie should loop 
and not the members loop property there can be
  --multiple instances of the same filmloop on the stage all behaving independantly

  tell sprite(me.spriteNum)
    pCurrentFrame=pCurrentFrame + pLoopDirection
    case pCurrentFrame of
      0:
        if pLoopStatus then
          pCurrentFrame=the lastFrame
          nextFrame=pCurrentFrame-1
        else
          pCurrentFrame=1
          nextFrame=the lastFrame
        end if
      1:
        nextFrame=the lastFrame
      (the lastFrame+1):
        if pLoopStatus then
          pCurrentFrame=1
          nextFrame=the lastFrame
        else
          pCurrentFrame=the lastFrame
          nextFrame=pCurrentFrame-1
        end if
      otherwise:
        nextFrame=pCurrentFrame-1
    end case
    go frame nextFrame
  end tell
end

on playLoop
  pLoopDirection=1
end

on pauseLoop
  pLoopDirection=0
end

on reverseLoop
  pLoopDirection=-1
end

on turnLoopingOn me
  pLoopStatus=1
end

on turnLoopingOff me
  pLoopStatus=0
end

on getPropertyDescriptionList me
  pdl=[:]

  pdl[#pLoopStatus]=[#comment:"Loop da loop", #default:0, #format:#boolean]
  pdl[#pLoopDirection]=[#comment:"Start the loop: playing(1), paused(0), 
reversing(-1)", #default:1, #format:#integer, #range:[1,0,-1]]

  return pdl
end

now you can simply call the appropriate sprite with

sendSprite(spriteNumOfLoop, #pauseLoop) to get it to pause
sendSprite(spriteNumOfLoop, #turnLoopingOn) to get it to loop through the animation
etc.

Once again I don't know if I'd use this as a final solution but it is fun to play 
around with this stuff. Maybe someday we'll have proper support for filmloops. If 
someone out there has a better method or can find a way to deal with the problems I 
describe in the commented code please let us know.

later,

Rob



[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/lingo-l.cgi  To post messages to the list,
email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo.  Thanks!]

Reply via email to