Articles Archive
Articles Search
Director Wiki
 

FilmStrips

September 28, 1998
by Pat McClellan

Dear Multimedia Handyman,

I am creating a Director movie in which I want to show a lot of still pictures. I want to display them as consecutive frames of a "film strip", so that the user can scroll from one to the next. Would you please advise me how best to handle the situation?

Dirk Dino

Dear Dirk,

There are a lot of ways to approach this situation. In one scenario, you could simply loop in a frame and handle the whole thing with lists of members and lists of locations on the screen. This is a fun challenge for Lingo enthusiasts, but I think it neglects using Director's easy score animation. I've opted for a combination of using the score and using a behavior to swap members when necessary. Because the score layout is important, I'm including the dir file for download (Mac or PC format).

In this movie, we're using the term filmstrip. This should not be confused with a Director film loop. When I refer to the "filmstrip", I'm talking about a 1 bit graphic member that looks like a strip of film, with sprocket holes on the sides. Also, our use of the term "frame" might be confusing. I'll try to be specific about whether I'm referring to a frame in the score, or a frame on the filmstrip.

My filmstrip member is larger than the stage height, so it extends off the top and bottom of the stage. The filmstrip is really only 4 film frames high. I've also labeled the frames of the filmstrip so that you can easily see how it is moving. Notice when you advance to the next photo, the filmstrip immediately "jumps" down by one full film frame, then animates back to its original position (over 15 frames in the score). This allows us to have a filmstrip as small as possible.

In addition to the filmstrip member, I've also created 7 small images which are substitutes for your photos. I've named my members according to their color. 7 photos is arbitrary... it could be as many as you want with no change in the setup or scripting. I put the first 4 "photos" (yellow, gray, cyan, and brown) in the score with a duration of 30 score frames, lined up with the film frames created by the filmstrip.

Then, I put a keyframe at frame 15 for all 4 sprites and set up the animation of all four "photo" sprites and the filmstrip sprite to move up one full "frame". I'll call this the "next" sequence. The last 15 frame of these sprites needs to be the reverse animation (moving down one full "frame"). Finally, I've set up markers with "go to the frame" frame scripts at frame 15 and 30.

Now for the Lingo. We'll need a behavior attached to the photo sprites. The behavior will be "activated" when the Next or Back button is pressed. Attach scripts to the next and back buttons which do this:


on mouseUp
  sendAllSprites (#nextMem, #forward)
  go to "next"
end

That will send a message to all sprites (our photo sprites) to run a handler called "nextMem". It will also tell it which direction to swap -- whether to swap to the next or previous cast member. For the Back button, the script is very similar:


on mouseUp
  sendAllSprites (#nextMem, #back)
  go to "last"
end

Now to write the behavior for the photo sprites. Basically, this will simply accept commands to swap, along with the instruction on which direction to swap. When a button gets pushed, and its script sends out the message to this behavior to run the nextMem handler in a particular direction, the behavior needs to do the following:

  1. Keep track of which memberNum (and castLibNum) the sprite currently is.
  2. Add 1 to the memberNum for #forward, or subtract 1 from the memberNum for #back.
  3. Check to see if the adjusted memberNum is less than the memberNum of the first photo in the series. If so, reset the memberNum to the last photo in the series.
  4. Check to see if the adjusted memberNum is more than the memberNum of the last photo in the series. If so, reset the memberNum to the first photo in the series.
  5. Set the member of this sprite to the new memberNum.

-- NextMem Behavior copyright © rpardi / at / tiac.net 1998, 
-- ZZP Online, LLC
-- created with Behavior Writer Xtra by 
-- Roy Pardi 
property pMySprite ¬
property pMemberNum
property pMyCastLib
property pLastMem
property pFirstMem
property pDirection

on getPropertyDescriptionList
  set d = [:]
  addProp d, #pFirstMem, [#default: 0, #format: ¬
    #member, #comment: "First member in series"]
  addProp d, #pLastMem, [#default: "0", #format: ¬
    #member, #comment: "Last member in series"]  
  return d
end
on beginSprite me
  set pMySprite = the spriteNum of me
  set myMem = the member of sprite pMySprite
  set pMemberNum = the memberNum of myMem
  set pMyCastLib =  the castLibNum of myMem
  set pLastMem = the memberNum of member pLastMem
  set pFirstMem = the memberNum of member pFirstMem
  set pDirection = #forward
end
on nextMem me, whichDirection
  if pDirection = whichDirection then
    if whichDirection = #forward then
      set pMemberNum = pMemberNum + 1
      if pMemberNum > pLastMem then
        set pMemberNum = pFirstMem
      end if
    else
      set pMemberNum = pMemberNum - 1
      if pMemberNum < pFirstMem then
        set pMemberNum = pLastMem
      end if
    end if
    set the member of sprite pMySprite = member ¬
      pMembernum of castLib pMyCastLib
  else -- change of direction
    set pDirection = whichDirection
  end if
end 
on getBehaviorDescription  
  set description = "This behavior swaps the ¬
    member of sprite to the next one in the cast."  
  return description
end

I've set up the behavior to make it easy to specify the first and last members in the series of photos. Good luck with your project.

Patrick McClellan is Director Online's co-founder. Pat is Vice President, Managing Director for Jack Morton Worldwide, a global experiential marketing company. He is responsible for the San Francisco office, which helps major technology clients to develop marketing communications programs to reach enterprise and consumer audiences.

Copyright 1997-2017, Director Online. Article content copyright by respective authors.