Contents
Articles
Behaviors
Books
Director News
Director Web Sites
FAQ
Games
Mailing Lists
News Groups
Project Examples
Reviews
Software
Tools
Useful Web Sites
Utilities
Xtras

Don't miss these
RADGrid
Swirl-Alphamania
Keycode
OpenDBC
Director 6.5 Stubs
Editable Field/Text AutoTabbing
ADOXtra Lite
Making the Projector Fill the Screen
MailTo Xtra
blending on casts
 

 

 

Behavior Gallery navigator

Added on 6/27/2004

 

Compatibilities:
D8 D8_5 D9 Mac PC

This item has not yet been rated

Author: Raschko

This script will cycle through a list of images based on a back or next button. It is very easy to implement; some naming conventions need apply.

Download PC Source
-- 27 June 2004, written By Brian Raschko

-- Variables -- globals.
global   myName
global   secondName
global   maxNum

global   ammount
global   tracker
global   recall
-- Variables -- Property Box specific.
Property description
property spriteNum
property mySprite

property myDownMember
property myStandardMember

property myCounter
property myThumbnail
property myControl

------------------
-- Main Scripts --
------------------

on beginSprite me
  
  myName = member(sprite(myThumbnail).member).name
  
  mySprite = sprite(me.spriteNum) -- Determine the Sprite for this Button.
  myStandardMember = mySprite.member -- Determine the default Member for this Button.
  
  if myControl = "Next" then
    
    findMaxNumber -- search a cast for instances of a member
    
  end if
  
end beginSprite

on mouseDown me
  
  mySprite.member = myDownMember -- Flip this button to the MouseDown Member.
  
  case myControl of
      
    "Next":    
      
      if integer(member(myCounter).text) <> maxNum then -- stop if
        
        member(myCounter).text = string(integer(member(myCounter).text) + 1) -- increase the counter
        
      end if
      
    "Back":
      
      if integer(member(myCounter).text) <> 1 then -- stop if
        
        member(myCounter).text = string(integer(member(myCounter).text) - 1) -- decrease the counter
        
      end if
      
  end case
  
  sprite(myThumbnail).member = member(secondName & member(myCounter).text) -- change to another thumbnail view
  
end mouseDown

on mouseUp me
  mySprite.member = myStandardMember -- Flip this button to the Default Member.
end mouseLeave

on mouseLeave me
  mySprite.member = myStandardMember -- Flip this button to the Default Member.
end mouseLeave

on findMaxNumber
  
  maxNum = 0 -- initialize the counter
  secondName = myName -- create a copy of the member name
  
  myCast = sprite(myThumbnail).castLibNum -- which cast do I reside in
  ammount = the number of members of castLib(myCast) -- number of members in said cast (legacy code)
  
  recall = the itemDelimiter      -- capture the base item spepperator
  the itemDelimiter = "_"         -- change the item sepperator
  myName = myName.item[2]         -- grab the second item of the member name
  secondName = secondName.item[1] -- grab the first item of the member name
  the itemDelimiter = recall      -- reset the item sepperator
  
  repeat with tracker = member(sprite(myThumbnail).member).membernum to ammount --repeat to the contents of the cast
    
    if member(tracker).name contains myName then -- compare member names
      
      maxNum = maxNum + 1  -- increase the counter value  
      
    end if
    
  end repeat
  
  secondName = secondName & "_" & myName & "_" -- reset the membername after being choped up
  
end

---------------------------------
-- Property "Pop-Up" Functions --
---------------------------------

on isOKToAttach (me, aSpriteType, aSpriteNum) -- What am I attached to?
  
  case aSpriteType of
    #graphic:
      return TRUE -- I can be attached to that. ( graphic = attached to a sprite )
    #script:
      return FALSE -- You can't attach ME to that!
  end case
  
end isOKToAttach

on getPropertyDescriptionList -- Open the Property "Pop-Up" Box.
  
  if the currentSpriteNum = 0 then exit -- Quit installation if not on the Timeline or a Sprite.
  
  theMember = sprite(mySprite).member --|__ My member Number
  theMemberNumber = theMember.number  --|
  
  description = [:] -- Declare the Property Variable Array.
  
  -- Add the Property Vairables.
  addprop description,#myDownMember, [#comment: "Display which member on MouseDown?",#format: #graphic, #default: member (theMemberNumber + 1)                 ]
  addprop description,#myControl,    [#comment: "Type of control?",                  #format: #string , #default: "Next", #range: ["Next", "Back"]             ]
  addprop description,#myThumbnail,  [#comment: "Sprite to change?",                 #format: #integer, #default: 1, #range: [#min: 1, #max: the lastChannel ] ]
  addprop description,#myCounter,    [#comment: "Display the image number where?",   #format: #field ,  #default: "URL"                                        ]
  
  -- Display these Variables.
  return description
  
end getPropertyDescriptionList

------------------------
-- Script Description --
------------------------

on getBehaviorDescription me
  RETURN
  "Thumbnail companion:" & RETURN & RETURN &
  "Parameters: " & RETURN &
  "    *Button states:" & RETURN &
  "       - Down" & RETURN &
  "    *Image number indicator." & RETURN &
  "    *What sprite to change." & RETURN & RETURN &
  QUOTE & "This scripte requires a text sprite as wel as" & RETURN &
  "two buttons; back and next. In comparison" & RETURN &
  "you can think of it as database navigation, if" & RETURN &
  "you have delt with this sort of a thing." & QUOTE & RETURN & RETURN &
  QUOTE & "In enabling this script we need to use specific naming conventions; almost like an" & RETURN &
  "array of sorts. For example..." & RETURN & RETURN &
  "number_name_number" & RETURN & RETURN &
  "The last number corrisponds to the variable inside the text member. Hence counting" & RETURN &
  "through your images." & RETURN & RETURN &
  "1_BLAH_1 , 1_BLAH_2 , 1_BLAH_3....ETC" & QUOTE
end getBehaviorDescription

 


Contact

MMI
36 South Court Sq
Suite 300
Newnan, GA 30263
USA

Send e-mail