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