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
Page turn
Sound not playing in Shockwave
Get browser versions
CopyFiles form AnyPath Include CD-ROM,DVD,HDD...etc
Universal Movie Pause Button
Dragging and Magnifying a Sprite
QuickTime VR 2
Toggle ButtonsEnabled Property of a Flash Member
Set FrameRate of a Flash Sprite
Wait for Flash to finish
 

 

 

Behavior Force Characters

Added on 6/22/2000

 

Compatibilities:
D7 D8 Mac PC Script Shockwave

This item has not yet been rated

Author: KumarK

Allows only permitted characters

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

Property spritenum,permittedchars,charssupported,allowall,Themember,customcharacters

------ Get Behavior Description List ------
on getPropertyDescriptionList me
  set description = [:]
  if the currentspritenum = 0 then exit
  addProp description, #permittedchars, [#comment: "Enter the permitted Charactes of the Field :" ,#format:#String, \
  #range:["Only Aplhabets","Only Numbers","Alphanumeric","Only Special Characters","Custom Characters","Allow all"],#default:"Alphanumeric"]
  addProp description, #customcharacters, [#comment: "Enter the Custom Characters here(use this only if you select custom characters from above) :" ,#format:#String,#default:"Enter Custom Characters here"]
  return description
end getPropertyDescriptionList
------ Get Behavior Description List ------

-- Get Behavior description --
on getBehaviorDescription me
  return \
    "Force Characters" & RETURN & RETURN & \
    "* Allows to enter only permitted Characters"
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
  set allowall=true
  TheMember = member (sprite (spriteNum).member)
  set the editable of sprite spriteNum to TRUE
  put "" into field TheMember
end
--- intialize field ---

-----on keydown event---
on keyDown  
  put the key into keyentered    
  case permittedchars of
    "Only Aplhabets":set charssupported="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
    "Only Numbers":  set charssupported ="0123456789"
    "Alphanumeric":  set charssupported="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
    "Only Special Characters":   set charssupported="`~!@#$%^&*()_-+=\|][{}';:/?.>,<" & quote & space
     "Custom Characters": set  charssupported = customcharacters
    "Allow all": set allowall=false
  end case
  if allowall=true then
    if charssupported contains keyentered then
      pass
    else if keyentered = BACKSPACE then
      pass
    else
      dontPassEvent
    end if
  else    
    member(TheMember).text  = member(TheMember).text & keyentered
  end if
end
-----on keydown event---

 


Contact

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

Send e-mail