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
Rotate Forever-Alphamania
Gravitational Force
Macromedia Flash 5 From Scratch
MailTo Xtra
Set DirectToStage Property of a Flash Member
A Star Lingo Pathfinding Algorithm
INM Impressario 4 for Director 11
simZip Xtra
Export Text for proofing
Set ButtonsEnabled Property of a Flash Sprite
 

 

 

Behavior Visted Sections

Added on 7/26/2000

 

Compatibilities:
behavior D7 D8 Mac PC Shockwave

This item has not yet been rated

Author: Shehal (website)

Creates a drop list of all visited markers.

-- marissaj ... baby ... this one is for you :-)
-- mailto: shehal@europa.unixville.com
-- Visit my shockwave site: http://www.unixville.com/~shehal
-- Visit marissaj's site: http://www.geocities.com/~marissaj

-- PLEASE NOTE:
-- on beginSprite me
--  put the labelList into member sprite(me.spriteNum).member
-- end
-- add the above script to a text field member to create a field member with ALL markers in your movie
-- you can then delete unwanted markers off and use this script


on getBehaviorDescription me
  return "
  Visted Sections"&RETURN&RETURN&"
Apply this behavior on a Field Member to create a drop-down list of the sections in your present movie."&RETURN&RETURN&"
ALL markers in your present movie will be included in the applied Field Member."&RETURN&"
You can later delete unwanted markers from the Field Member."&RETURN&"
Sections visited by the user will be indicated in italics"&RETURN&RETURN&"
PLEASE NOTE:"&RETURN&RETURN&"
on beginSprite me"&RETURN&"
  put the labelList into member sprite(me.spriteNum).member"&RETURN&"
end"&RETURN&"
Add the above script to a text field member to create a field member with ALL markers in your movie and you can then delete unwanted markers off and use this script"&RETURN
  
end getBehaviorDescription

property memberTextField
property spriteTextField

property clickedStatus

property rL, rT, rR, rB
-- rect parameters
property lH
-- Line hight of text field

property nL
-- Number of lines to display in drop-down list

property currentVisitedSection

property nameTextFile
property pathTextFile
property fileVisitedSections

property clickStatus
property statusFileUpdate

property visitedSections
property allSections
property lineNo
-- mouse line number

on beginSprite me
  -- obtain the Sections list
  spriteTextField = sprite(me.spriteNum)
  memberTextField = sprite(me.spriteNum).member
  
  member(memberTextField).boxType = #fixed
  member(memberTextField).boxDropShadow = FALSE
  
  lH = member(memberTextField).lineHeight
  rectTextField = member(memberTextField).rect
  
  rL = rectTextField.left
  rR = rectTextField.right
  rT = rectTextField.top
  rB = lH
  
  member(memberTextField).scrollTop = 1
  member(memberTextField).rect = rect(rL, rT, rR, rB)
  updateStage
  
  clickStatus = FALSE
  -- FALSE = clicked to drop down
  -- TRUE = clicked to select Section
  
  -- create the Visited Sections text file
  
  if statusFileUpdate = TRUE then
    if objectP(fileVisitedSections) then set fileVisitedSections = 0
    set fileVisitedSections = new(xtra "fileio")
    createFile(fileVisitedSections, pathTextFile&nameTextFile&".txt")
    closeFile(fileVisitedSections)
    set fileVisitedSections = 0
  end if
  
  -- read the Visited Sections text file
  if objectP(fileVisitedSections) then set fileVisitedSections = 0
  set fileVisitedSections = new(xtra "fileio")
  set fileName = pathTextFile&nameTextFile&".txt"
  if not voidP(filename) and not (filename = EMPTY) then
    openFile(fileVisitedSections, filename, 1)
    if status(fileVisitedSections) = 0 then
      set visitedSections = readFile(fileVisitedSections)
      closeFile(fileVisitedSections)
      set fileVisitedSections = 0
    end if
  end if
  
  -- check if visitedSections is valid (suggested by Chuck)
  if voidP(visitedSections) = TRUE then
    set visitedSections = ""
  end if
  
  -- update Sections
  allSections = the text of member memberTextField
  set nSectionsList = the number of lines in allSections
  set nVisitedSections = the number of lines in visitedSections
  
  repeat with n = 1 to nSectionsList
    repeat with m = 1 to nVisitedSections
      if line (n) of allSections = line (m) of visitedSections then
        set the fontStyle of line (n) of member (memberTextField) to "italic"
        delete line (m) of visitedSections
      end if
    end repeat
  end repeat
  
end beginSprite

on mouseUp me
  -- drop the Sections list down
  member(memberTextField).boxType = #scroll
  rB = lH*nL  
  member(memberTextField).rect = rect(rL, rT, rR, rB)
  updateStage
  
  -- set the selected Section as VISITED
  lineNo = the mouseLine
  
  if clickStatus = TRUE then
    currentVisitedSection = allSections.line[lineNo]
    -- change font style of current visited section  
    set the fontStyle of line (lineNo) of member (memberTextField) to "italic"
    
    -- update the Visited Sections text file
    if statusFileUpdate = TRUE then
      if objectP(fileVisitedSections) then set fileVisitedSections = 0
      set theFile = currentVisitedSection&RETURN
      set fileVisitedSections = new(xtra "fileio")
      createFile(fileVisitedSections, pathTextFile&nameTextFile&".txt")
      openFile(fileVisitedSections, pathTextFile&nameTextFile&".txt",0)
      setPosition(fileVisitedSections,getLength(fileVisitedSections))
      writeString(fileVisitedSections, theFile)
      closeFile(fileVisitedSections)
      set fileVisitedSections = 0
    end if
    
    -- go to current visited section
    go to frame currentVisitedSection
  else
    clickStatus = TRUE
  end if
end mouseUp

on prepareFrame me
  -- hilite the pointed section
  if the mouseLine > 0 then
    hilite line the mouseLine of field memberTextField
    updateStage
  else
    -- close drop down list if outside
    rB = lH
    member(memberTextField).boxType = #fixed
    member(memberTextField).rect = rect(rL, rT, rR, rB)
    updateStage
  end if
end prepareFrame

on getPropertyDescriptionList  
  set description = [:]
  addProp description, #nL, [#default: 10, #format: #integer, #comment: "Number of lines to display in drop-down list:"]
  addProp description, #pathTextFile, [ #default: the moviePath, #format: #string, #comment: "Path of Text File:"]
  addProp description, #nameTextFile, [ #default: "boohaha", #format: #string, #comment: "Name of Text File:"]
  addProp description, #statusFileUpdate, [ #default: TRUE, #format: #boolean, #comment: "Update to text file? (Y/N):"]
  return description
end getPropertyDescriptionList  

 


Contact

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

Send e-mail