Search content:

 

Personal Menu
Username:
Password:
Save password

Become a member

Forgot Password?

 

Don't miss these
Set Display Properties
ROLLOVER FADES
First Class Text Picture
Check QuickTime Version
Creating an object that simulates an array
Toggle ImageEnabled Property of a Flash Member
Simple Character Substitution
ScreenFade
Hold on a frame till sound finishes playing
StuntRacer
MediaMacros Xtras Mall
 

 

 

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---

 


Upload Provided by ABCUpload ASP

Contact

MMI
22 West Court Sq
Suite 2C
Newnan, GA 30263
USA

Fax - (206) 339-5833

Send e-mail