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
myFile
Drag & Drop
Editable Field/Text AutoTabbing
Library for work with formatted text documents
System Info into a field member
Ceiling and Floor
Go to URL
Flip Sprite - Make a sprite appear to rotate in 3-D space.
Ripple General Settings-Alphamania
Watcher Window Behavior
 

 

 

Behavior Password Checking

Added on 6/20/2000

 

Compatibilities:
behavior D7 D8 Mac PC Shockwave

Rating:

Author: KumarK

Password Checking

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

Property spritenum,mypassword,passwordmask,passwordcormsg,passwordcornext,beepforpasscor,Nooftries,passincorrectmsg
property passwordincornext,beepforpassincor,TheMember,currentlyentered,currenttryno,prompt

------ Get Behavior Description List ------
on getPropertyDescriptionList me
  set description = [:]
  if the currentspritenum = 0 then exit
  passwordcharlist=["*","@","#","%","$","&","!","X"]
  passwordcorrectlist=["Go Next frame","Go Next Marker"]
  passwordincorrectlist=["Exit","Go Previous Marker","Go Loop"]
  addProp description, #mypassword, [#comment: "Enter Password here :" ,#format:#String,#default:""]
  addProp description, #passwordmask, [#comment: "Select Password Character :",#format:#string,#range:passwordcharlist,#default:passwordcharlist[1]]  
  addProp description, #prompt, [#comment: "Enter default Text here :",#format:#string, #default:"Enter password here"]
  addProp description, #passwordcormsg, [#comment: "Alert message If password is correct(leave empty if not needed) :",#format:#string, \
  #default:"Congrats, Password is correct"]
  addProp description, #passwordcornext, [#comment: "What next If Passowrd is correct :",#format:#string, #range:passwordcorrectlist, \
  #default:passwordcorrectlist[1]]
  addProp description, #beepforpasscor, [#comment: "Beep if password is correct :",#format:#boolean, #default:True]  
  addProp description, #Nooftries, [#comment: "Choose Number of tries :",#format:#Integer,#range:[#min:1,#max:10], #default:1]  
  addProp description, #passincorrectmsg, [#comment: "Alert message If password is incorrect(leave empty if not needed) :",#format:#string, \
  #default:"Password is Incorrect"]
  addProp description, #passwordincornext, [#comment: "What next If Passowrd is correct :",#format:#string, #range:passwordincorrectlist, \
  #default:passwordincorrectlist[1]]
  addProp description, #beepforpassincor, [#comment: "Beep if password is Incorrect :",#format:#boolean, #default:True]    
  return description
end getPropertyDescriptionList
------ Get Behavior Description List ------

-- Get Behavior description --
on getBehaviorDescription me
  return \
    "Password Checking" & RETURN & RETURN & \
    "This Behavior Checks for the specified Passoword and does perticular action depending on correct or incorrect." & RETURN & RETURN & \
    "Drop this on a field member on the stage." & RETURN & RETURN & \
  "PARAMETERS:" & RETURN & \
    "* Password" & RETURN & \
    "* Password Mask character" & RETURN & \
    "* Default Text(prompt)" & RETURN & \
    "* Alert message if Password is correct" & RETURN & \
    "* What Next if Password is correct" & RETURN & \
    "* Beep if Passoward is correct" & RETURN & \
    "Number of Tries" & RETURN & \
    "* Alert message if Password is Incorrect" & RETURN & \
    "* What Next if Password is Incorrect" & RETURN & \
    "* Beep if Passoward is Incorrect"
end getBehaviorDescription
-- Get Behavior description --

--- Available for only field members on the stage ----
on isOKToAttach (me, aSpriteType, aSpriteNum)
  case aSpriteType of
    #graphic:
      return getPos([#field], sprite(aSpriteNum).member.type) <> 0
    #script:
      return FALSE
  end case
end isOKToAttach
--- Available for only field members on the stage ----

--- intialize field ---
on beginSprite me
  TheMember = member (sprite (spriteNum).member)
  set the editable of sprite spriteNum to TRUE
  put prompt into field TheMember
  set currentlyentered to ""
  set currenttryno to 0
end
--- intialize field ---

-----on keydown event---
on keyDown me
  case (the key) of
    RETURN:
      if currentlyentered = mypassword then AcceptPassword
      else RejectPassword
    BACKSPACE:
      set currentlyentered to ""
    otherwise:
      set permittedChars to "abcdefghijklmnopqrstuvwxyz 1234567890"
      if permittedChars contains the key then
        if field TheMember = prompt then put passwordmask into field TheMember
        else put passwordmask after field TheMember
        put the key after currentlyentered
      end if
  end case
  stopEvent
end
-----on keydown event---

on AcceptPassword
  if passwordcormsg <> "" then
    alert passwordcormsg
  end if
  if beepforpasscor = true then
    if Nooftries > 1 then
      beep Nooftries
    else
      beep 1
    end if
  end if  
  case passwordcornext of
    "Go Next frame": Go the frame + 1
    "Go Next Marker":Go Next
  end case
end


on RejectPassword
  if currenttryno >= Nooftries then
    if passincorrectmsg <> "" then
      alert passincorrectmsg
    end if
    
    if beepforpassincor = true then
      if Nooftries > 1 then
        beep Nooftries
      else
        beep 1
      end if
    end if
    
    
    case passwordincornext of
      "Exit":quit
      "Go Previous Marker": Go Previous
      "Go Loop": Go loop
    end case
  else
    currenttryno = currenttryno + 1
  end if
  put prompt into field TheMember
  set currentlyentered to ""
end

 


Contact

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

Send e-mail