Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- as2
- scaleform
- addChild
- MMOKit
- 샌프란시스코
- autodesk
- 플래시
- 형변환
- CLIK
- as3
- Document Class
- 클릭
- scaleform3
- 스케일폼
- watch
- flash cs3
- flash
- scaleform4
- 애드온
- 강좌
- Chart
- flash player 10
- 태그클라우드
- DataBinding
- 수학정석
- GDC
- as3.0
- 집합의 연산
- ApplicationDomain
- KGC 2013
Archives
- Today
- Total
scaleform.minarto.com
완성형 한글 Class 본문
가상 키보드를 만들다가 만든건데... 클라이언트가 2.0을 원해서 2.0으로 만들었습니다.
테스트는 좀 더 충분히 해봐야 하지만... 뭐, 그야 각자에 맡기고....
class com.minarto.text.CreateKorean
{
function CreateKorean() { }
/*
_last_str : 마지막 글자
_new_str : 합쳐질 글자
*/
static function join(_last_str:String, _new_str:String):String
{
var lastCode:Number = _last_str.charCodeAt(0); // 마지막 글자의 문자코드
var newCode:Number = _new_str.charCodeAt(0); // 합쳐질 글자의 문자코드
if(lastCode >= 12593 && lastCode <= 12622) // 이전 글자가 초성일 때
{
_last_str = join1(_last_str, _new_str);
}
else if(lastCode >= 12623 && lastCode <= 12643) // 이전 글자가 중성일 때
{
_last_str = join2(_last_str, _new_str);
}
else if((lastCode - 44032) % 28 == 0 && (lastCode >= 44032 && lastCode <= 55176)) // 이전 글자가 중성인 글자일 때
{
_last_str = join3(_last_str, _new_str);
}
else if((lastCode - 44032) % 28 >= 1 && (lastCode >= 44033 && lastCode <= 55203)) // 이전 글자가 종성인 글자일 때
{
_last_str = join4(_last_str, _new_str);
}
else
{
_last_str += _new_str;
}
return _last_str;
}
// 이전 글자가 초성일 때
static function join1(_last_str:String, _new_str:String):String
{
var lastCode:Number = _last_str.charCodeAt(0); // 마지막 글자의 문자코드
var newCode:Number = _new_str.charCodeAt(0); // 합쳐질 글자의 문자코드
if(newCode >= 12593 && newCode <= 12622) // 뒤에 초성이 붙을 때
{
if(_last_str == "ㄱ") // ㄱ 뒤에 초성이 붙을 때
{
switch(_new_str)
{
case "ㅅ" :
_last_str = "ㄳ";
break;
default :
_last_str += _new_str;
}
}
else if(_last_str == "ㄴ") // ㄴ 뒤에 초성이 붙을 때
{
switch(_new_str)
{
case "ㅈ" :
_last_str = "ㄵ";
break;
case "ㅎ" :
_last_str = "ㄶ";
break;
default :
_last_str += _new_str;
}
}
else if(_last_str == "ㄹ") // ㄹ 뒤에 초성이 붙을 때
{
switch(_new_str)
{
case "ㄱ" :
_last_str = "ㄺ";
break;
case "ㅁ" :
_last_str = "ㄻ";
break;
case "ㅂ" :
_last_str = "ㄼ";
break;
case "ㅅ" :
_last_str = "ㄽ";
break;
case "ㅌ" :
_last_str = "ㄾ";
break;
case "ㅍ" :
_last_str = "ㄿ";
break;
case "ㅎ" :
_last_str = "ㅀ";
break;
default :
_last_str += _new_str;
}
}
else if(_last_str == "ㅂ") // ㄹ 뒤에 초성이 붙을 때
{
switch(_new_str)
{
case "ㅅ" :
_last_str = "ㅄ";
break;
default :
_last_str += _new_str;
}
}
else
{
_last_str += _new_str;
}
}
else if(newCode >= 12623 && newCode <= 12643) // 뒤에 중성이 붙을 때
{
switch(_last_str)
{
case "ㄱ" :
_last_str = String.fromCharCode(44032 + (newCode - 12623) * 28);
break;
case "ㄲ" :
_last_str = String.fromCharCode(44620 + (newCode - 12623) * 28);
break;
case "ㄴ" :
_last_str = String.fromCharCode(45208 + (newCode - 12623) * 28);
break;
case "ㄷ" :
_last_str = String.fromCharCode(45796 + (newCode - 12623) * 28);
break;
case "ㄸ" :
_last_str = String.fromCharCode(46384 + (newCode - 12623) * 28);
break;
case "ㄹ" :
_last_str = String.fromCharCode(46972 + (newCode - 12623) * 28);
break;
case "ㅁ" :
_last_str = String.fromCharCode(47560 + (newCode - 12623) * 28);
break;
case "ㅂ" :
_last_str = String.fromCharCode(48148 + (newCode - 12623) * 28);
break;
case "ㅃ" :
_last_str = String.fromCharCode(48736 + (newCode - 12623) * 28);
break;
case "ㅅ" :
_last_str = String.fromCharCode(49324 + (newCode - 12623) * 28);
break;
case "ㅆ" :
_last_str = String.fromCharCode(49912 + (newCode - 12623) * 28);
break;
case "ㅇ" :
_last_str = String.fromCharCode(50500 + (newCode - 12623) * 28);
break;
case "ㅈ" :
_last_str = String.fromCharCode(51088 + (newCode - 12623) * 28);
break;
case "ㅉ" :
_last_str = String.fromCharCode(51676 + (newCode - 12623) * 28);
break;
case "ㅊ" :
_last_str = String.fromCharCode(52264 + (newCode - 12623) * 28);
break;
case "ㅋ" :
_last_str = String.fromCharCode(52852 + (newCode - 12623) * 28);
break;
case "ㅌ" :
_last_str = String.fromCharCode(53440 + (newCode - 12623) * 28);
break;
case "ㅍ" :
_last_str = String.fromCharCode(54028 + (newCode - 12623) * 28);
break;
case "ㅎ" :
_last_str = String.fromCharCode(54616 + (newCode - 12623) * 28);
break;
default :
_last_str += _new_str;
}
}
else
{
_last_str += _new_str;
}
return _last_str;
}
// 이전 글자가 중성일 때
static function join2(_last_str:String, _new_str:String):String
{
var lastCode:Number = _last_str.charCodeAt(0); // 마지막 글자의 문자코드
var newCode:Number = _new_str.charCodeAt(0); // 합쳐질 글자의 문자코드
if(newCode >= 12623 && newCode <= 12643) // 뒤에 중성이 붙을 때
{
if(_last_str == "ㅗ")
{
switch(_new_str) // 초성 뒤에 중성이 붙을 때
{
case "ㅏ" :
_last_str = "ㅘ";
break;
case "ㅐ" :
_last_str = "ㅙ";
break;
case "ㅣ" :
_last_str = "ㅚ";
break;
default :
_last_str += _new_str;
}
}
else if(_last_str == "ㅜ")
{
switch(_new_str) // 초성 뒤에 중성이 붙을 때
{
case "ㅓ" :
_last_str = "ㅝ";
break;
case "ㅔ" :
_last_str = "ㅞ";
break;
case "ㅣ" :
_last_str = "ㅟ";
break;
default :
_last_str += _new_str;
}
}
else if(_last_str == "ㅡ")
{
switch(_new_str) // 초성 뒤에 중성이 붙을 때
{
case "ㅣ" :
_last_str = "ㅢ";
break;
default :
_last_str += _new_str;
}
}
else
{
_last_str += _new_str;
}
}
else
{
_last_str += _new_str;
}
return _last_str;
}
// 이전 글자가 중성인 글자일 때
static function join3(_last_str:String, _new_str:String):String
{
var lastCode:Number = _last_str.charCodeAt(0); // 마지막 글자의 문자코드
var newCode:Number = _new_str.charCodeAt(0); // 합쳐질 글자의 문자코드
if(newCode >= 12623 && newCode <= 12643) // 뒤에 모음이 붙을 때
{
// 모음이 ㅗ 로 끝나고 모음이 붙을 때
if((lastCode - 44256) % 588 == 0 && (_new_str == "ㅏ" || _new_str == "ㅐ" || _new_str == "ㅣ"))
{
switch(_new_str) // 초성 뒤에 중성이 붙을 때
{
case "ㅏ" :
_last_str = String.fromCharCode(lastCode + 28);
break;
case "ㅐ" :
_last_str = String.fromCharCode(lastCode + 28 * 2);
break;
case "ㅣ" :
_last_str = String.fromCharCode(lastCode + 28 * 3);
break;
default :
_last_str += _new_str;
}
}
// 모음이 ㅜ 로 끝나고 모음이 붙을 때
else if((lastCode - 44396) % 588 == 0 && (_new_str == "ㅓ" || _new_str == "ㅔ" || _new_str == "ㅣ"))
{
switch(_new_str) // 초성 뒤에 중성이 붙을 때
{
case "ㅓ" :
_last_str = String.fromCharCode(lastCode + 28);
break;
case "ㅔ" :
_last_str = String.fromCharCode(lastCode + 28 * 2);
break;
case "ㅣ" :
_last_str = String.fromCharCode(lastCode + 28 * 3);
break;
default :
_last_str += _new_str;
}
}
// 모음이 ㅡ 로 끝나고 모음이 붙을 때
else if((lastCode - 44536) % 588 == 0 && (_new_str == "ㅣ"))
{
switch(_new_str) // 초성 뒤에 중성이 붙을 때
{
case "ㅣ" :
_last_str = String.fromCharCode(lastCode + 28);
break;
default :
_last_str += _new_str;
}
}
else
{
_last_str += _new_str;
}
}
else if(newCode >= 12593 && newCode <= 12622) // 종성이 붙을 때
{
switch(_new_str)
{
case "ㄱ" :
_last_str = String.fromCharCode(lastCode + 1);
break;
case "ㄲ" :
_last_str = String.fromCharCode(lastCode + 2);
break;
case "ㄴ" :
_last_str = String.fromCharCode(lastCode + 4);
break;
case "ㄷ" :
_last_str = String.fromCharCode(lastCode + 7);
break;
case "ㄹ" :
_last_str = String.fromCharCode(lastCode + 8);
break;
case "ㅁ" :
_last_str = String.fromCharCode(lastCode + 16);
break;
case "ㅂ" :
_last_str = String.fromCharCode(lastCode + 17);
break;
case "ㅅ" :
_last_str = String.fromCharCode(lastCode + 19);
break;
case "ㅆ" :
_last_str = String.fromCharCode(lastCode + 20);
break;
case "ㅇ" :
_last_str = String.fromCharCode(lastCode + 21);
break;
case "ㅈ" :
_last_str = String.fromCharCode(lastCode + 22);
break;
case "ㅊ" :
_last_str = String.fromCharCode(lastCode + 23);
break;
case "ㅋ" :
_last_str = String.fromCharCode(lastCode + 24);
break;
case "ㅌ" :
_last_str = String.fromCharCode(lastCode + 25);
break;
case "ㅍ" :
_last_str = String.fromCharCode(lastCode + 26);
break;
case "ㅎ" :
_last_str = String.fromCharCode(lastCode + 27);
break;
default :
_last_str += _new_str;
}
}
else
{
_last_str += _new_str;
}
return _last_str;
}
// 이전 글자가 종성인 글자일 때
static function join4(_last_str:String, _new_str:String):String
{
var lastCode:Number = _last_str.charCodeAt(0); // 마지막 글자의 문자코드
var newCode:Number = _new_str.charCodeAt(0); // 합쳐질 글자의 문자코드
if(newCode >= 12623 && newCode <= 12643) // 뒤에 모음이 붙을 때
{
switch((lastCode - 44032) % 28)
{
case 1 : // ㄱ 종성일 때
_last_str = String.fromCharCode(lastCode - 1) + join("ㄱ", _new_str);
break;
case 2 : // ㄲ 종성일 때
_last_str = String.fromCharCode(lastCode - 2) + join("ㄲ", _new_str);
join()
break;
case 3 : // ㄳ 종성일 때
_last_str = String.fromCharCode(lastCode - 2) + join("ㅅ", _new_str);
break;
case 4 : // ㄴ 종성일 때
_last_str = String.fromCharCode(lastCode - 4) + join("ㄴ", _new_str);
break;
case 5 : // ㄵ 종성일 때
_last_str = String.fromCharCode(lastCode - 1) + join("ㅈ", _new_str);
break;
case 6 : // ㄶ 종성일 때
_last_str = String.fromCharCode(lastCode - 2) + join("ㅎ", _new_str);
break;
case 7 : // ㄷ 종성일 때
_last_str = String.fromCharCode(lastCode - 7) + join("ㄷ", _new_str);
break;
case 8 : // ㄹ 종성일 때
_last_str = String.fromCharCode(lastCode - 8) + join("ㄹ", _new_str);
break;
case 9 : // ㄺ 종성일 때
_last_str = String.fromCharCode(lastCode - 1) + join("ㄱ", _new_str);
break;
case 10 : // ㄻ 종성일 때
_last_str = String.fromCharCode(lastCode - 2) + join("ㅁ", _new_str);
break;
case 11 : // ㄼ 종성일 때
_last_str = String.fromCharCode(lastCode - 3) + join("ㅂ", _new_str);
break;
case 12 : // ㄽ 종성일 때
_last_str = String.fromCharCode(lastCode - 4) + join("ㅅ", _new_str);
break;
case 13 : // ㄾ 종성일 때
_last_str = String.fromCharCode(lastCode - 5) + join("ㅌ", _new_str);
break;
case 14 : // ㄿ 종성일 때
_last_str = String.fromCharCode(lastCode - 6) + join("ㅍ", _new_str);
break;
case 15 : // ㅀ 종성일 때
_last_str = String.fromCharCode(lastCode - 7) + join("ㅎ", _new_str);
break;
case 16 : // ㅁ 종성일 때
_last_str = String.fromCharCode(lastCode - 16) + join("ㅁ", _new_str);
break;
case 17 : // ㅂ 종성일 때
_last_str = String.fromCharCode(lastCode - 17) + join("ㅂ", _new_str);
break;
case 18 : // ㅄ 종성일 때
_last_str = String.fromCharCode(lastCode - 1) + join("ㅅ", _new_str);
break;
case 19 : // ㅅ 종성일 때
_last_str = String.fromCharCode(lastCode - 19) + join("ㅅ", _new_str);
break;
case 20 : // ㅆ 종성일 때
_last_str = String.fromCharCode(lastCode - 20) + join("ㅆ", _new_str);
break;
case 21 : // ㅇ 종성일 때
_last_str = String.fromCharCode(lastCode - 21) + join("ㅇ", _new_str);
break;
case 22 : // ㅈ 종성일 때
_last_str = String.fromCharCode(lastCode - 22) + join("ㅈ", _new_str);
break;
case 23 : // ㅊ 종성일 때
_last_str = String.fromCharCode(lastCode - 23) + join("ㅊ", _new_str);
break;
case 24 : // ㅋ 종성일 때
_last_str = String.fromCharCode(lastCode - 24) + join("ㅋ", _new_str);
break;
case 25 : // ㅌ 종성일 때
_last_str = String.fromCharCode(lastCode - 25) + join("ㅌ", _new_str);
break;
case 26 : // ㅍ 종성일 때
_last_str = String.fromCharCode(lastCode - 26) + join("ㅍ", _new_str);
break;
case 27 : // ㅎ 종성일 때
_last_str = String.fromCharCode(lastCode - 27) + join("ㅎ", _new_str);
break;
default :
_last_str += _new_str;
}
}
else if(newCode >= 12593 && newCode <= 12622) // 뒤에 자음이 붙을 때
{
if((lastCode - 44033) % 28 == 0) // ㄱ 종성일 때
{
switch(_new_str)
{
case "ㅅ" : // 종성일 때
_last_str = String.fromCharCode(lastCode + 2);
break;
default :
_last_str += _new_str;
}
}
else if((lastCode - 44036) % 28 == 0) // ㄴ 종성일 때
{
switch(_new_str)
{
case "ㅈ" : // 종성일 때
_last_str = String.fromCharCode(lastCode + 1);
break;
case "ㅎ" : // 종성일 때
_last_str = String.fromCharCode(lastCode + 2);
break;
default :
_last_str += _new_str;
}
}
else if((lastCode - 44040) % 28 == 0) // ㄹ 종성일 때
{
switch(_new_str)
{
case "ㄱ" : // 종성일 때
_last_str = String.fromCharCode(lastCode + 1);
break;
case "ㅁ" : // 종성일 때
_last_str = String.fromCharCode(lastCode + 2);
break;
case "ㅂ" : // 종성일 때
_last_str = String.fromCharCode(lastCode + 3);
break;
case "ㅅ" : // 종성일 때
_last_str = String.fromCharCode(lastCode + 4);
break;
case "ㅌ" : // 종성일 때
_last_str = String.fromCharCode(lastCode + 5);
break;
case "ㅍ" : // 종성일 때
_last_str = String.fromCharCode(lastCode + 6);
break;
case "ㅎ" : // 종성일 때
_last_str = String.fromCharCode(lastCode + 7);
break;
default :
_last_str += _new_str;
}
}
else if((lastCode - 44049) % 28 == 0) // ㅂ 종성일 때
{
switch(_new_str)
{
case "ㅅ" : // 종성일 때
_last_str = String.fromCharCode(lastCode + 1);
break;
default :
_last_str += _new_str;
}
}
else
{
_last_str += _new_str;
}
}
else
{
_last_str += _new_str;
}
return _last_str;
}
}
{
function CreateKorean() { }
/*
_last_str : 마지막 글자
_new_str : 합쳐질 글자
*/
static function join(_last_str:String, _new_str:String):String
{
var lastCode:Number = _last_str.charCodeAt(0); // 마지막 글자의 문자코드
var newCode:Number = _new_str.charCodeAt(0); // 합쳐질 글자의 문자코드
if(lastCode >= 12593 && lastCode <= 12622) // 이전 글자가 초성일 때
{
_last_str = join1(_last_str, _new_str);
}
else if(lastCode >= 12623 && lastCode <= 12643) // 이전 글자가 중성일 때
{
_last_str = join2(_last_str, _new_str);
}
else if((lastCode - 44032) % 28 == 0 && (lastCode >= 44032 && lastCode <= 55176)) // 이전 글자가 중성인 글자일 때
{
_last_str = join3(_last_str, _new_str);
}
else if((lastCode - 44032) % 28 >= 1 && (lastCode >= 44033 && lastCode <= 55203)) // 이전 글자가 종성인 글자일 때
{
_last_str = join4(_last_str, _new_str);
}
else
{
_last_str += _new_str;
}
return _last_str;
}
// 이전 글자가 초성일 때
static function join1(_last_str:String, _new_str:String):String
{
var lastCode:Number = _last_str.charCodeAt(0); // 마지막 글자의 문자코드
var newCode:Number = _new_str.charCodeAt(0); // 합쳐질 글자의 문자코드
if(newCode >= 12593 && newCode <= 12622) // 뒤에 초성이 붙을 때
{
if(_last_str == "ㄱ") // ㄱ 뒤에 초성이 붙을 때
{
switch(_new_str)
{
case "ㅅ" :
_last_str = "ㄳ";
break;
default :
_last_str += _new_str;
}
}
else if(_last_str == "ㄴ") // ㄴ 뒤에 초성이 붙을 때
{
switch(_new_str)
{
case "ㅈ" :
_last_str = "ㄵ";
break;
case "ㅎ" :
_last_str = "ㄶ";
break;
default :
_last_str += _new_str;
}
}
else if(_last_str == "ㄹ") // ㄹ 뒤에 초성이 붙을 때
{
switch(_new_str)
{
case "ㄱ" :
_last_str = "ㄺ";
break;
case "ㅁ" :
_last_str = "ㄻ";
break;
case "ㅂ" :
_last_str = "ㄼ";
break;
case "ㅅ" :
_last_str = "ㄽ";
break;
case "ㅌ" :
_last_str = "ㄾ";
break;
case "ㅍ" :
_last_str = "ㄿ";
break;
case "ㅎ" :
_last_str = "ㅀ";
break;
default :
_last_str += _new_str;
}
}
else if(_last_str == "ㅂ") // ㄹ 뒤에 초성이 붙을 때
{
switch(_new_str)
{
case "ㅅ" :
_last_str = "ㅄ";
break;
default :
_last_str += _new_str;
}
}
else
{
_last_str += _new_str;
}
}
else if(newCode >= 12623 && newCode <= 12643) // 뒤에 중성이 붙을 때
{
switch(_last_str)
{
case "ㄱ" :
_last_str = String.fromCharCode(44032 + (newCode - 12623) * 28);
break;
case "ㄲ" :
_last_str = String.fromCharCode(44620 + (newCode - 12623) * 28);
break;
case "ㄴ" :
_last_str = String.fromCharCode(45208 + (newCode - 12623) * 28);
break;
case "ㄷ" :
_last_str = String.fromCharCode(45796 + (newCode - 12623) * 28);
break;
case "ㄸ" :
_last_str = String.fromCharCode(46384 + (newCode - 12623) * 28);
break;
case "ㄹ" :
_last_str = String.fromCharCode(46972 + (newCode - 12623) * 28);
break;
case "ㅁ" :
_last_str = String.fromCharCode(47560 + (newCode - 12623) * 28);
break;
case "ㅂ" :
_last_str = String.fromCharCode(48148 + (newCode - 12623) * 28);
break;
case "ㅃ" :
_last_str = String.fromCharCode(48736 + (newCode - 12623) * 28);
break;
case "ㅅ" :
_last_str = String.fromCharCode(49324 + (newCode - 12623) * 28);
break;
case "ㅆ" :
_last_str = String.fromCharCode(49912 + (newCode - 12623) * 28);
break;
case "ㅇ" :
_last_str = String.fromCharCode(50500 + (newCode - 12623) * 28);
break;
case "ㅈ" :
_last_str = String.fromCharCode(51088 + (newCode - 12623) * 28);
break;
case "ㅉ" :
_last_str = String.fromCharCode(51676 + (newCode - 12623) * 28);
break;
case "ㅊ" :
_last_str = String.fromCharCode(52264 + (newCode - 12623) * 28);
break;
case "ㅋ" :
_last_str = String.fromCharCode(52852 + (newCode - 12623) * 28);
break;
case "ㅌ" :
_last_str = String.fromCharCode(53440 + (newCode - 12623) * 28);
break;
case "ㅍ" :
_last_str = String.fromCharCode(54028 + (newCode - 12623) * 28);
break;
case "ㅎ" :
_last_str = String.fromCharCode(54616 + (newCode - 12623) * 28);
break;
default :
_last_str += _new_str;
}
}
else
{
_last_str += _new_str;
}
return _last_str;
}
// 이전 글자가 중성일 때
static function join2(_last_str:String, _new_str:String):String
{
var lastCode:Number = _last_str.charCodeAt(0); // 마지막 글자의 문자코드
var newCode:Number = _new_str.charCodeAt(0); // 합쳐질 글자의 문자코드
if(newCode >= 12623 && newCode <= 12643) // 뒤에 중성이 붙을 때
{
if(_last_str == "ㅗ")
{
switch(_new_str) // 초성 뒤에 중성이 붙을 때
{
case "ㅏ" :
_last_str = "ㅘ";
break;
case "ㅐ" :
_last_str = "ㅙ";
break;
case "ㅣ" :
_last_str = "ㅚ";
break;
default :
_last_str += _new_str;
}
}
else if(_last_str == "ㅜ")
{
switch(_new_str) // 초성 뒤에 중성이 붙을 때
{
case "ㅓ" :
_last_str = "ㅝ";
break;
case "ㅔ" :
_last_str = "ㅞ";
break;
case "ㅣ" :
_last_str = "ㅟ";
break;
default :
_last_str += _new_str;
}
}
else if(_last_str == "ㅡ")
{
switch(_new_str) // 초성 뒤에 중성이 붙을 때
{
case "ㅣ" :
_last_str = "ㅢ";
break;
default :
_last_str += _new_str;
}
}
else
{
_last_str += _new_str;
}
}
else
{
_last_str += _new_str;
}
return _last_str;
}
// 이전 글자가 중성인 글자일 때
static function join3(_last_str:String, _new_str:String):String
{
var lastCode:Number = _last_str.charCodeAt(0); // 마지막 글자의 문자코드
var newCode:Number = _new_str.charCodeAt(0); // 합쳐질 글자의 문자코드
if(newCode >= 12623 && newCode <= 12643) // 뒤에 모음이 붙을 때
{
// 모음이 ㅗ 로 끝나고 모음이 붙을 때
if((lastCode - 44256) % 588 == 0 && (_new_str == "ㅏ" || _new_str == "ㅐ" || _new_str == "ㅣ"))
{
switch(_new_str) // 초성 뒤에 중성이 붙을 때
{
case "ㅏ" :
_last_str = String.fromCharCode(lastCode + 28);
break;
case "ㅐ" :
_last_str = String.fromCharCode(lastCode + 28 * 2);
break;
case "ㅣ" :
_last_str = String.fromCharCode(lastCode + 28 * 3);
break;
default :
_last_str += _new_str;
}
}
// 모음이 ㅜ 로 끝나고 모음이 붙을 때
else if((lastCode - 44396) % 588 == 0 && (_new_str == "ㅓ" || _new_str == "ㅔ" || _new_str == "ㅣ"))
{
switch(_new_str) // 초성 뒤에 중성이 붙을 때
{
case "ㅓ" :
_last_str = String.fromCharCode(lastCode + 28);
break;
case "ㅔ" :
_last_str = String.fromCharCode(lastCode + 28 * 2);
break;
case "ㅣ" :
_last_str = String.fromCharCode(lastCode + 28 * 3);
break;
default :
_last_str += _new_str;
}
}
// 모음이 ㅡ 로 끝나고 모음이 붙을 때
else if((lastCode - 44536) % 588 == 0 && (_new_str == "ㅣ"))
{
switch(_new_str) // 초성 뒤에 중성이 붙을 때
{
case "ㅣ" :
_last_str = String.fromCharCode(lastCode + 28);
break;
default :
_last_str += _new_str;
}
}
else
{
_last_str += _new_str;
}
}
else if(newCode >= 12593 && newCode <= 12622) // 종성이 붙을 때
{
switch(_new_str)
{
case "ㄱ" :
_last_str = String.fromCharCode(lastCode + 1);
break;
case "ㄲ" :
_last_str = String.fromCharCode(lastCode + 2);
break;
case "ㄴ" :
_last_str = String.fromCharCode(lastCode + 4);
break;
case "ㄷ" :
_last_str = String.fromCharCode(lastCode + 7);
break;
case "ㄹ" :
_last_str = String.fromCharCode(lastCode + 8);
break;
case "ㅁ" :
_last_str = String.fromCharCode(lastCode + 16);
break;
case "ㅂ" :
_last_str = String.fromCharCode(lastCode + 17);
break;
case "ㅅ" :
_last_str = String.fromCharCode(lastCode + 19);
break;
case "ㅆ" :
_last_str = String.fromCharCode(lastCode + 20);
break;
case "ㅇ" :
_last_str = String.fromCharCode(lastCode + 21);
break;
case "ㅈ" :
_last_str = String.fromCharCode(lastCode + 22);
break;
case "ㅊ" :
_last_str = String.fromCharCode(lastCode + 23);
break;
case "ㅋ" :
_last_str = String.fromCharCode(lastCode + 24);
break;
case "ㅌ" :
_last_str = String.fromCharCode(lastCode + 25);
break;
case "ㅍ" :
_last_str = String.fromCharCode(lastCode + 26);
break;
case "ㅎ" :
_last_str = String.fromCharCode(lastCode + 27);
break;
default :
_last_str += _new_str;
}
}
else
{
_last_str += _new_str;
}
return _last_str;
}
// 이전 글자가 종성인 글자일 때
static function join4(_last_str:String, _new_str:String):String
{
var lastCode:Number = _last_str.charCodeAt(0); // 마지막 글자의 문자코드
var newCode:Number = _new_str.charCodeAt(0); // 합쳐질 글자의 문자코드
if(newCode >= 12623 && newCode <= 12643) // 뒤에 모음이 붙을 때
{
switch((lastCode - 44032) % 28)
{
case 1 : // ㄱ 종성일 때
_last_str = String.fromCharCode(lastCode - 1) + join("ㄱ", _new_str);
break;
case 2 : // ㄲ 종성일 때
_last_str = String.fromCharCode(lastCode - 2) + join("ㄲ", _new_str);
join()
break;
case 3 : // ㄳ 종성일 때
_last_str = String.fromCharCode(lastCode - 2) + join("ㅅ", _new_str);
break;
case 4 : // ㄴ 종성일 때
_last_str = String.fromCharCode(lastCode - 4) + join("ㄴ", _new_str);
break;
case 5 : // ㄵ 종성일 때
_last_str = String.fromCharCode(lastCode - 1) + join("ㅈ", _new_str);
break;
case 6 : // ㄶ 종성일 때
_last_str = String.fromCharCode(lastCode - 2) + join("ㅎ", _new_str);
break;
case 7 : // ㄷ 종성일 때
_last_str = String.fromCharCode(lastCode - 7) + join("ㄷ", _new_str);
break;
case 8 : // ㄹ 종성일 때
_last_str = String.fromCharCode(lastCode - 8) + join("ㄹ", _new_str);
break;
case 9 : // ㄺ 종성일 때
_last_str = String.fromCharCode(lastCode - 1) + join("ㄱ", _new_str);
break;
case 10 : // ㄻ 종성일 때
_last_str = String.fromCharCode(lastCode - 2) + join("ㅁ", _new_str);
break;
case 11 : // ㄼ 종성일 때
_last_str = String.fromCharCode(lastCode - 3) + join("ㅂ", _new_str);
break;
case 12 : // ㄽ 종성일 때
_last_str = String.fromCharCode(lastCode - 4) + join("ㅅ", _new_str);
break;
case 13 : // ㄾ 종성일 때
_last_str = String.fromCharCode(lastCode - 5) + join("ㅌ", _new_str);
break;
case 14 : // ㄿ 종성일 때
_last_str = String.fromCharCode(lastCode - 6) + join("ㅍ", _new_str);
break;
case 15 : // ㅀ 종성일 때
_last_str = String.fromCharCode(lastCode - 7) + join("ㅎ", _new_str);
break;
case 16 : // ㅁ 종성일 때
_last_str = String.fromCharCode(lastCode - 16) + join("ㅁ", _new_str);
break;
case 17 : // ㅂ 종성일 때
_last_str = String.fromCharCode(lastCode - 17) + join("ㅂ", _new_str);
break;
case 18 : // ㅄ 종성일 때
_last_str = String.fromCharCode(lastCode - 1) + join("ㅅ", _new_str);
break;
case 19 : // ㅅ 종성일 때
_last_str = String.fromCharCode(lastCode - 19) + join("ㅅ", _new_str);
break;
case 20 : // ㅆ 종성일 때
_last_str = String.fromCharCode(lastCode - 20) + join("ㅆ", _new_str);
break;
case 21 : // ㅇ 종성일 때
_last_str = String.fromCharCode(lastCode - 21) + join("ㅇ", _new_str);
break;
case 22 : // ㅈ 종성일 때
_last_str = String.fromCharCode(lastCode - 22) + join("ㅈ", _new_str);
break;
case 23 : // ㅊ 종성일 때
_last_str = String.fromCharCode(lastCode - 23) + join("ㅊ", _new_str);
break;
case 24 : // ㅋ 종성일 때
_last_str = String.fromCharCode(lastCode - 24) + join("ㅋ", _new_str);
break;
case 25 : // ㅌ 종성일 때
_last_str = String.fromCharCode(lastCode - 25) + join("ㅌ", _new_str);
break;
case 26 : // ㅍ 종성일 때
_last_str = String.fromCharCode(lastCode - 26) + join("ㅍ", _new_str);
break;
case 27 : // ㅎ 종성일 때
_last_str = String.fromCharCode(lastCode - 27) + join("ㅎ", _new_str);
break;
default :
_last_str += _new_str;
}
}
else if(newCode >= 12593 && newCode <= 12622) // 뒤에 자음이 붙을 때
{
if((lastCode - 44033) % 28 == 0) // ㄱ 종성일 때
{
switch(_new_str)
{
case "ㅅ" : // 종성일 때
_last_str = String.fromCharCode(lastCode + 2);
break;
default :
_last_str += _new_str;
}
}
else if((lastCode - 44036) % 28 == 0) // ㄴ 종성일 때
{
switch(_new_str)
{
case "ㅈ" : // 종성일 때
_last_str = String.fromCharCode(lastCode + 1);
break;
case "ㅎ" : // 종성일 때
_last_str = String.fromCharCode(lastCode + 2);
break;
default :
_last_str += _new_str;
}
}
else if((lastCode - 44040) % 28 == 0) // ㄹ 종성일 때
{
switch(_new_str)
{
case "ㄱ" : // 종성일 때
_last_str = String.fromCharCode(lastCode + 1);
break;
case "ㅁ" : // 종성일 때
_last_str = String.fromCharCode(lastCode + 2);
break;
case "ㅂ" : // 종성일 때
_last_str = String.fromCharCode(lastCode + 3);
break;
case "ㅅ" : // 종성일 때
_last_str = String.fromCharCode(lastCode + 4);
break;
case "ㅌ" : // 종성일 때
_last_str = String.fromCharCode(lastCode + 5);
break;
case "ㅍ" : // 종성일 때
_last_str = String.fromCharCode(lastCode + 6);
break;
case "ㅎ" : // 종성일 때
_last_str = String.fromCharCode(lastCode + 7);
break;
default :
_last_str += _new_str;
}
}
else if((lastCode - 44049) % 28 == 0) // ㅂ 종성일 때
{
switch(_new_str)
{
case "ㅅ" : // 종성일 때
_last_str = String.fromCharCode(lastCode + 1);
break;
default :
_last_str += _new_str;
}
}
else
{
_last_str += _new_str;
}
}
else
{
_last_str += _new_str;
}
return _last_str;
}
}