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
Replace returns with PC line breaks
Go to net page button/frame
Number of CD Tracks - MCI
Vector Shape - Create Ellipse
Nero
Flash Component Label
USBXtra
OnStage Media for Director
Gallery navigator
OggXtra
 

 

 

Behavior JTMR Yo Style Writer

Added on 4/20/2000

 

Compatibilities:
behavior D7 D8 Mac PC Shockwave

This item has not yet been rated

Author: ElianChrebor

This behavior converts what you type in "yo" style... in real time. Yo Style??? ü ùÑÐêR§TâÑРѤW?? Use this behavior with field and text members only. Of course, the field (text) member must be editable.

Download PC Source    Download Mac Source
-- JTMR
-- YO STYLE
-- WRITER
-- ==================================================
-- Converts what you type in 'Yo' style...
-- €ôÑVéRT§ WHàT ù T¥Þê îÑ Ýô §TÝ£ë...
-- ==================================================
-- © 2000 - JTMR
-- ==================================================

-- globals

-- properties
property caseStyle
property alternatePos, elite, realLetters, yoLetters

-- scripts
on beginSprite me
  -- checks whether sprite(me.spriteNum).member is a valid member
  if not(getOne([#Text, #Field], sprite(me.spriteNum).member.type)) then
    alert "JTMR YoStyle Writer" & Return & Return & "Use this behavior with a text or a field member." & Return & "µ§é THî§ ßêHàVíôR WïTHà Tê×T ôR â Fîë£Ð MéMßéR."
    return 0
  end if
  
  me.alternatePos = 0
  -- Yo ABC Definition
  me.realLetters = [¬
  "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", ¬
  "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]
  me.yoLetters = [¬
  ["à", "â", "ä"], [], ["c", "ç", "¢", "©"], [], ["ê", "ë", "é"], [], [], [], ["í", "ï", "î"], [], [], ["1"], [], ["ñ"], ["ô", "ö", "¤"], ["þ"], [], ["®"], ["$"], [], ["µ", "ù", "û", "ü"], [], [], [], ["ý", "ÿ"], [], ¬
  ["Å", "Ã", "Á"] , ["ß"] , ["€"], ["Ð"], ["Ë", "Ê", "É"], [], [], [], ["Í", "Ï"], [], [], ["£"], [], ["Ñ"], ["Õ", "Ó", "ø"], ["Þ"], [], [], ["§"], [], ["Ù", "Ü"], [], [], ["×"], ["¥", "Ý"], []]
  me.elite = [1, 5, 9, 15, 21, 27, 31, 35, 41, 47]
end beginSprite

on keyDown me
  if getOne([1, 4, 8, 9, 28, 29, 30, 31, 127], charToNum(the key)) then pass
  -- real-time conversion
  JTMRYoWrite(me)
end keyDown

on JTMRYoWrite me
  -- checks whether the letter is known in the Yo ABC
  i = getOne(me.realLetters, the key)
  
  if i then
    -- case style management
    case me.caseStyle of
      "Don't touch it!!" :
        ii = i
      "rANdOm" :
        ii = (i + random(10)*26) MOD 52
        if ii = 0 then ii=52
      "lowercase" :
        ii = i MOD 26
        if ii = 0 then ii = 26
      "UPPERCASE" :
        ii = 26 + i MOD 26
        if ii = 26 then ii=52
      "aLtErNaTe 1" :
        if not(me.alternatePos) then
          ii = i MOD 26
          if ii = 0 then
            ii = 26
          end if      
        else
          ii = 26 + i MOD 26
          if ii = 26 then
            ii=52
          end if
        end if
        me.alternatePos = (me.alternatePos + 1) MOD 2        
      "AlTeRnAtE 2" :
        if (me.alternatePos) then
          ii = i MOD 26
          if ii = 0 then
            ii = 26
          end if      
        else
          ii = 26 + i MOD 26
          if ii = 26 then
            ii=52
          end if
        end if
        me.alternatePos = (me.alternatePos + 1) MOD 2
      "ElItE" :
        if getOne(me.elite, i) then
          ii = 26 + i MOD 26
          if ii = 26 then
            ii=52
          end if
        else
          ii = i MOD 26
          if ii = 0 then
            ii = 26
          end if
        end if
      "aNTi eLiTe" :
        if not(getOne(me.elite, i)) then
          ii = 26 + i MOD 26
          if ii = 26 then
            ii=52
          end if
        else
          ii = i MOD 26
          if ii = 0 then
            ii = 26
          end if
        end if        
    end case    
    cc = me.yoLetters[ii].count
    if cc then
      myLetter = me.yoLetters[ii][random(cc)]  
    else
      myLetter = me.realLetters[ii]
    end if
  else  
    myLetter = the key
  end if
  
  -- modifies typed text and manages actions on selected text
  if the selStart > 0 then
    sprite(me.spriteNum).member.text = sprite(me.spriteNum).member.text.char[1..the selStart] & ¬
                                                          myLetter & ¬
                                                          sprite(me.spriteNum).member.text.char[the selEnd+1..sprite(me.spriteNum).member.text.length]
  else
    sprite(me.spriteNum).member.text = myLetter & ¬
                                                           sprite(me.spriteNum).member.text.char[the selEnd+1..sprite(me.spriteNum).member.text.length]
  end if
  the selStart = the selStart +1
  the selEnd = the selStart  
  
end JTMRYoWrite

-- ==================================================
on getPropertyDescriptionList
  myPropertylist = [:]
  addProp myPropertyList, #caseStyle, [#Comment: "Select case style", #format: #string, ¬
                                                              #range: ["Don't touch it!!",  "rANdOm", "lowercase", "UPPERCASE", "aLtErNaTe 1", "AlTeRnAtE 2", "ElItE", "aNTi eLiTe"], #default: "rANdOm"]
  return myPropertyList
end getPropertyDescriptionList

on getBehaviorDescription
  return "JTMR Behavior Library" & RETURN &¬
         "© 2000 - JTMR" & RETURN &¬
         "jtmr@worldnet.fr" & RETURN &¬
         "http://services.worldnet.fr/elian-c" & RETURN & RETURN &¬
         "JTMR YoStyleWriter Behavior" & RETURN & RETURN &¬
         "Converts what you type in 'Yo' style..." & RETURN &¬
         "€ôÑVéRT§ WHàT ù T¥Þê îÑ Ýô §TÝ£ë" & RETURN & RETURN &¬
         "This behavior is free software; you can redistribute it and/or modify "  &¬
         "it under the terms of the GNU General Public License as published by "  &¬
         "the Free Software Foundation; either version 2 of the License, or (at "  &¬
         "your option) any later version. "  &¬
         "This program is distributed in the hope that it will be useful, but "  &¬
         "WITHOUT ANY WARRANTY; without even the implied warranty of "  &¬
         "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU "  &¬
         "General Public License for more details. "  &¬
         "You should have received a copy of the GNU General Public License "  &¬
         "along with this program; if not, write to the Free Software "  &¬
         "Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA."
end getBehaviorDescription
-- ==================================================

 


Contact

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

Send e-mail