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
Dir Player
Draw a line with lingo
sound volum
Building a Generic Card Shuffler
Set FrameRate of a Animated GIF Sprite
Go Marker of a Movie in current Directory
Stub Mac Projector
Find a drive with a specific name/Find CD Drives
Scroll Text With Mouse
Havok Skittles / Bowling Game source code
 

 

 

Behavior Play Soundfile

Added on 6/12/2000

 

Compatibilities:
behavior D7 D8 Mac PC Shockwave

This item has not yet been rated

Author: KumarK

Play Soundfile

---- written for Director 8 ---
---- Kumar.K kumark@icode.com ----

-- custom properties --
property soundchannel,WhereTo,folderlist,theFile,subfolders,fileslist,result


------ Get Behavior Description List ------
on getPropertyDescriptionList me
  set description = [:]
  filelist=getfilelist(me)
  if   filelist.count > 0 then  
    addProp description, #soundchannel, [#comment: "Sound Channel Number", #format:#Integer, #range:[#min:1,#Max:8],#default:1]
    addProp description, #theFile, [#comment: "Select the File Nmae You Wantto Play :", #format:#String,#range:filelist,#default:filelist[1]]
    if the currentspritenum = 0 then
      SetaProp description, #WhereTo, [#comment: "Where To Attach" ,#format:#String, \
    #range:["On EnterFrame","On ExitFrame"],#default:"On EnterFrame"]
    else
      SetaProp description, #WhereTo, [#comment: "Where To Attach" ,#format:#String, \
    #range:["On MouseUp","On MouseDown","On MouseEnter","On MouseLeave"],#default:"On MouseUp"]    
    end if    
    return description
  else
    alertme
  end if
end getPropertyDescriptionList
------ Get Behavior Description List ------

-- Get Behavior description --
on getBehaviorDescription
  return "This Behavior Plays the selected sound file. " & RETURN & RETURN &\
"This Behavior Requires Buddy API to Get filenames,so please make sure uyou have Buddy API Xtra. " & RETURN & RETURN &\
  "Parameters" & RETURN & \
  "* Sound Channel" & RETURN & \
  "* File Name" & RETURN & \
  "* Where to attach this script"
end
-- Get Behavior description --

------ Can be attached to only Script Channel ------
on isOKToAttach (me, aSpriteType, aSpriteNum)
  case aSpriteType of
    #script:
      return true
    #graphic:
      return true      
  end case
end isOKToAttach
------ Can be attached to only Script Channel ------

-- give alert message --
on alertme
  alert "No Sound Files Found"
end
-- give alert message --

--- search for soundfile ---
on getfilelist me
  set mypath=the moviepath
  set fileslist=[]
  set Folders = baFolderList( mypath )
  set Files = baFileList( mypath ,"*.*")
  
  repeat with M=1 to Files.count
    findext files[m]    
    if (result=true) then
      fileslist.append(files[m])
    end if
  end repeat
  repeat with i = 1 to folders.count
    set subfolders = baFolderList( mypath & "\" & folders[i])
    if subfolders.count <> 0 then
      repeat with j=1 to subfolders.count
        set Files = baFileList( mypath & " \" &  folders[i] & "\" & subfolders[j],"*.*")
        repeat with k=1 to Files.count
          findext files[k]    
          if (result=true) then  
            fileslist.append(folders[i] & "\" & subfolders[j] & "\" & files[k])
          end if
        end repeat
      end repeat
      set Files = baFileList( mypath & " \" &  folders[i],"*.*")    
      repeat with j=1 to Files.count
        findext files[j]    
        if (result=true) then          
          fileslist.append(folders[i] & "\" & files[j])
        end if
      end repeat    
    else
      set Files = baFileList( mypath & " \" &  folders[i],"*.*")
      repeat with j=1 to Files.count
        findext files[j]    
        if (result=true) then
          fileslist.append(folders[i] & "\" & files[j])
        end if
      end repeat
    end if      
  end repeat
  return fileslist
end
--- search for soundfile ---

--- find out extension --
on findext source
  result=chars(source,the length of source - 3,the length of source)
  if result=".wav" or result=".swa" or result= ".au" or result=".aif" or result = ".mp3" then
    result=true
  else
    result=false
  end if
  return result
end if
end findnext
--- find out extension --


---play sound --
on playsoundfile
sound playFile soundchannel, the moviePath & thefile
end
---play sound --

-- Events --
on EnterFrame me
if WhereTo = "On EnterFrame" then
playsoundfile
end if
end EnterFrame

on ExitFrame me
if WhereTo = "On EnterFrame" then
playsoundfile
end if
end ExitFrame

on MouseUp
if WhereTo = "On MouseUp" then
playsoundfile
end if
end MouseUp

on MouseDown
if WhereTo = "On MouseDown" then
playsoundfile
end if
end MouseDown

on MouseEnter
if WhereTo = "On MouseEnter" then
playsoundfile
end if
end MouseEnter

on MouseLeave
if WhereTo = "On MouseLeave" then
playsoundfile
end if
end MouseLeave
-- Events --

 


Contact

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

Send e-mail