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
Lower Case
Object Serializer
ADOXtra Lite
Lingo Web Logs / Journals
VideoCodecCheck
Rotate a Flash Sprite
Direct Media Volume Slider
Convert Data
Amara Flash Intro and Banner Builder
Get the computer name of user
 

 

 

Behavior Limited Fields

Added on 12/19/1999

 

Compatibilities:
behavior D7 D8 Mac PC Shockwave

This item has not yet been rated

Author: MediaMacros (website)

This is a simple behavior for text and field members that does the following... Limit a field to certain Characters, Limit a field to a certain NUMBER of characters, Turn the word wrap on/off for the field Enhanced on 9/20/2005 by Dean Utian - fixed so backspace, and arrows work

----

-- Restrict Chars behavior covering backspace/delete/left-right arrows/return/enter/home/end


property spriteNum, maxText, allowedKeys, myWrap, otherHandler



on getPropertyDescriptionList me

  p_list = [:]

  p_list.addProp(#maxText, [#format : #integer, #comment : "Max number of allowed Characters:", #default : 20])

  p_list.addProp(#allowedKeys, [#format : #string, #comment : "Keys to pass to field (Leave blank for all):", #default : "1234567890abcdefghijklmnopqrstuvwxyz"])

  p_list.addProp(#myWrap, [#format : #boolean, #comment : "Allow word wrapping?", #default : 0])

  return p_list

end



on beginSprite me

  sprite(spriteNum).member.wordwrap = myWrap

end



on keyDown me

  case the keyCode of

      --    51,117: -- backspace/delete

      --    115,119: left/right arrow

      --    123,124: -- home/end

      --    36: -- enter/return

    51,117,123,124:

      pass

    36,115,119:

      dontpassevent

    otherwise

      if allowedKeys contains the key and allowedKeys <> "" then

        if sprite(me.spriteNum).member.char.count < maxText then pass

      

      else if allowedKeys = "" then

        pass

      

      else

        dontpassevent        

      

      end if

  end case





on getBehaviorDescription me

  describe = "This is a simple behavior for text and field members that does the following..." & return

  describe = describe & "Limit a field to certain Characters" & return & "Limit a field to a certain NUMBER of characters" & "Turn the word wrap on/off for the field"

end

 


Contact

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

Send e-mail