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
Golden Gate
3DPI
Play/ Pause/ Rewind/ StepForward/ StepBackward Video Sprite
Calculating the day of the date
OS Control
Behavior Documentor
Setup Anim
File Association and save
Rotate Click-Alphamania
Password Checking
 

 

 

Article Password Protection in a Projector

Added on 7/12/1999

 

Compatibilities:
D7 D8 Mac PC Shockwave

This item has not yet been rated

Author: MediaMacros (website)

How can I make my projector "password protected?" I want to have it so only certain users can view the content and they will need a valid id to proceed.

If you want to keep a user out of your project unless they have "clearance" it isn't as difficult as you might think.  Start with the first frame of you movie being set up as a password entry screen.  Include one field (set to editable and fixed size) and any instructions, etc.  Then put a simple "go to the frame" handler on the exitFrame script.

Now that we have the basic setup, we need to decide what the script will need to do.  First, we don't want wandering eyes to pick up the password, so we need to filter the keys to the field to show a "*" for each letter.  Next we want to allow only alpha-numeric characters to be entered as well a a space, a period and maybe even a dash.  Finally we want the password to be checked when the user presses the enter key and if it is correct, advance to a designated frame.  We can allow a set number of failed attempts and retries as well.  

After setting up the necessary properties for the behavior (the correct password, where to go if correct, current number of tries, and maximum number of tries) we need to set a beginSprite handler that will ensure the field is editable and that the previous text is cleared out.  We are also going to need a property to store the current password attempt as the text in the field will be a series of "*" characters, and not the actual input.  First lets filter the key strokes.  Since we want to only effect the keys pressed while the field is active, we can make an on keyDown me handler in the behavior.  This allows us to intercept any keystroke before it gets sent to the field itself.  We will have 3 types of keys.  The return key, any valid characters, and finally everything else that should be ignored.  For this we can use a simple if statement to check if the key was the return key, then see if it was any of the allows keys (using the contains argument) and finally telling Director not to pass any other data to the field with a dontPassEvent call.  Below is the finished code...

property spriteNum, password, theMarker, tries, currentWord, totalTries
on beginSprite me
  tries = 0
  currentWord = ""
  sprite(spriteNum).member.text = ""
  sprite(spriteNum).member.editable = true
end

on keyDown me
  if tries = void then tries = 0
  if the key = return then
    dontPassEvent
    if currentWord = password then
      go theMarker
    else
      alert "Incorrect password."
      tries = tries + 1
        if tries >= totalTries then
          alert "Invalid User"
          quit
        end if
        currentWord = ""
        sprite(spriteNum).member.text = ""
      end if
    else
    dontPassEvent
    if the keyCode = 51 then
      if currentWord.char.count > 1 then
        howMany = (currentWord.char.count - 1)
        currentWord = currentWord.char[1..howMany]
      else
        currentWord = ""
      end if
    else
      if "1234567890abcdefghijklmnopqrstuvwxyz-. " contains the key then
        currentWord = currentWord & the key
      end if
    end if
    theText = ""
    if currentWord.char.count > 0 then
      repeat with x = 1 to currentWord.char.count
        theText = theText & "*"
      end repeat
    end if
    sprite(spriteNum).member.text = theText
  end if
end

on getPropertyDescriptionList me
  p_list = [:]
  addProp p_list, #password, [#format :#string, #default :"myPassword", #comment :"The password"]
  addProp p_list, #theMarker, [#format :#marker, #default :#next, #comment :"Where to go if correct"]
  addProp p_list, #totalTries, [#format :#integer, #default :4, #comment :"Number of tries"]
  return p_list
end

on getBehaviorDescription me
  return "Use this on a field to require password access to a projector. Parameters include the correct password, where to go if correct, and the number of allowed attempts."
end


You can add variations to it to allow for a user name and a password and even use an algorithm to customize a "key" for each user.  Using Xtras like Buddy API you can also write to the system registry to record a users registration and thus skip the registration process the next time.  

 


Contact

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

Send e-mail