(복수 문자간의 이동)
핵심원리
1. start type(임의의 시작문자)과 final type(최종적으로 보여주고자 하는 문자열)을 지정한다. ( 우리는 "-"와 "superman"로 합니다.)
2. superman의 각 문자를 배열을 이용하여 저장한다.
3."--------" =>"superman" (목적-->종착 ) 두 문자를 유니코드로 변경한다.
3. 각 문자에 순차적으로 deley를 주어 단계적으로 변환하도록 한다.
(0번째 배열의 이동시작 x초 후 1번째 배열 이동시작 ) 즉 ("-"=>"s", "-"=>"u","-"=>"p" 의 이동이 x초 간격으로 일어난다.)
4. 유니코드를 다시 문자열로 변화해서 화면에 표시
** 하단의 debugging 결과를 보면 순차적으로 코드이동이 있음을 확인 할 수 있다.
==================================
http://www.yugop.com/
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.text.TextField;
[ SWF ( width="550", height="400", frameRate="36", backgroundColor="0xEEEEEE" ) ]
public class TypoTest2 extends Sprite
{
private var tf: TextField = new TextField();
private var finalString: String = "superman !!";
private var arrFinalCode: Array = [];
private var arrCurrentCode: Array = [];
private var arrDelay: Array = [];
// 목적지 까지 도착했는지를 저장하는 변수
private var arrIsComplete: Array = [];
public function TypoTest2()
{
super();
// 목적 문자열의 각 코드번호를 this.arrFinalCode에 저장하고
// "-"의 코드번호를 this.arrCurrentCode에 저장하기
// arrCurrentCode[ i ] ----> arrFinalCode[ i ]로 가면 된다..!!
for( var i: int=0; i<finalString.length; i++ )
{
this.arrFinalCode[ i ] = this.finalString.charCodeAt( i );
this.arrCurrentCode[ i ] = "-".charCodeAt( 0 );
this.arrDelay[ i ] = -2*i;
this.arrIsComplete[ i ] = false;
}
// 텍스트 필드 화면에 붙이고
this.addChild( tf );
// 이벤트 설정
this.addEventListener( Event.ENTER_FRAME, onEnter );
}
private function onEnter( e: Event ): void
{
// arrCurrentCode[ i ] ----> arrFinalCode[ i ]로 이동하기 / Delay를 주어 순차적으로 시작하도록 한다.
for( var i: int=0; i<this.finalString.length; i++ )
{
if( ++ this.arrDelay[ i ] > 0 ){
if( this.arrCurrentCode[ i ] > this.arrFinalCode[ i ] ){
this.arrCurrentCode[ i ] --;
}else if( this.arrCurrentCode[ i ] < this.arrFinalCode[ i ] ){
this.arrCurrentCode[ i ] ++;
}else{
this.arrIsComplete[ i ] = true;
}
}
}// for
// 모두 목적지에 도착하면, 이벤트 삭제하는 코드
var totalComplete: Boolean = true;
for( i=0; i<this.finalString.length; i++ )
{
if( this.arrIsComplete[ i ] == false )
{
totalComplete = false;
}
}
if( totalComplete == true )
{
this.removeEventListener( Event.ENTER_FRAME, onEnter );
}
// arrCurrentCode에 해당하는 코드로부터.. 문자열 연결해서 만들기
var str: String = "";
for( i =0; i<this.finalString.length; i++ )
{
str += String.fromCharCode( this.arrCurrentCode[ i ] );
trace(str);
}
// 만든 문자열을 텍스트 필드에 대입하기
this.tf.text = str;
}
} // class
} // package
.
.-
.--
.---
.----
.-----
.------
.-------
.--------
.---------
.----------
/
/-
/--
/---
/----
/-----
/------
/-------
/--------
/---------
/----------
[SWF] Users:hyemisong:Documents:Flex Builder 3:ex0210:bin-debug:TypoTextEx2.swf - 2,125 bytes after decompression
0
0.
0.-
0.--
0.---
0.----
0.-----
0.------
0.-------
0.--------
0.---------
1
1/
1/-
1/--
1/---
1/----
1/-----
1/------
1/-------
1/--------
1/---------
2
20
20.
20.-
20.--
20.---
20.----
20.-----
20.------
20.-------
20.--------
3
31
31/
31/-
31/--
31/---
31/----
31/-----
31/------
31/-------
31/--------
4
42
420
420.
420.-
420.--
420.---
420.----
420.-----
420.------
420.-------
5
53
531
531/
531/-
531/--
531/---
531/----
531/-----
531/------
531/-------
6
64
642
6420
6420.
6420.-
6420.--
6420.---
6420.----
6420.-----
6420.------
7
75
753
7531
7531/
7531/-
7531/--
7531/---
7531/----
7531/-----
7531/------
8
86
864
8642
86420
86420.
86420.-
86420.--
86420.---
86420.----
86420.-----
9
97
975
9753
97531
97531/
97531/-
97531/--
97531/---
97531/----
97531/-----
:
:8
:86
:864
:8642
:86420
:86420.
:86420.-
:86420.--
:86420.---
:86420.----
;
;9
;97
;975
;9753
;97531
;97531/
;97531/-
;97531/--
;97531/---
;97531/----
<
<:
<:8
<:86
<:864
<:8642
<:86420
<:86420.
<:86420.-
<:86420.--
<:86420.---
=
=;
=;9
=;97
=;975
=;9753
=;97531
=;97531/
=;97531/-
=;97531/--
=;97531/---
>
><
><:
><:8
><:86
><:864
><:8642
><:86420
><:86420,
><:86420,-
><:86420,--
?
?=
?=;
?=;9
?=;97
?=;975
?=;9753
?=;97531
?=;97531+
?=;97531+-
?=;97531+--
@
@>
@><
@><:
@><:8
@><:86
@><:864
@><:8642
@><:8642*
@><:8642*,
@><:8642*,-
A
A?
A?=
A?=;
A?=;9
A?=;97
A?=;975
A?=;9753
A?=;9753)
A?=;9753)+
A?=;9753)+-
B
B@
B@>
B@><
B@><:
B@><:8
B@><:86
B@><:864
B@><:864(
B@><:864(*
B@><:864(*,
C
CA
CA?
CA?=
CA?=;
CA?=;9
CA?=;97
CA?=;975
CA?=;975'
CA?=;975')
CA?=;975')+
D
DB
DB@
DB@>
DB@><
DB@><:
DB@><:8
DB@><:86
DB@><:86&
DB@><:86&(
DB@><:86&(*
E
EC
ECA
ECA?
ECA?=
ECA?=;
ECA?=;9
ECA?=;97
ECA?=;97%
ECA?=;97%'
ECA?=;97%')
F
FD
FDB
FDB@
FDB@>
FDB@><
FDB@><:
FDB@><:8
FDB@><:8$
FDB@><:8$&
FDB@><:8$&(
G
GE
GEC
GECA
GECA?
GECA?=
GECA?=;
GECA?=;9
GECA?=;9#
GECA?=;9#%
GECA?=;9#%'
H
HF
HFD
HFDB
HFDB@
HFDB@>
HFDB@><
HFDB@><:
HFDB@><:"
HFDB@><:"$
HFDB@><:"$&
I
IG
IGE
IGEC
IGECA
IGECA?
IGECA?=
IGECA?=;
IGECA?=;!
IGECA?=;!#
IGECA?=;!#%
J
JH
JHF
JHFD
JHFDB
JHFDB@
JHFDB@>
JHFDB@><
JHFDB@><
JHFDB@>< "
JHFDB@>< "$
K
KI
KI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^\ZX !
fdb`^\ZX !!
g
ge
gec
geca
geca_
geca_]
geca_][
geca_][Y
geca_][Y
geca_][Y !
geca_][Y !!
h
hf
hfd
hfdb
hfdb`
hfdb`^
hfdb`^\
hfdb`^\Z
hfdb`^\Z
hfdb`^\Z !
hfdb`^\Z !!
i
ig
ige
igec
igeca
igeca_
igeca_]
igeca_][
igeca_][
igeca_][ !
igeca_][ !!
j
jh
jhf
jhfd
jhfdb
jhfdb`
jhfdb`^
jhfdb`^\
jhfdb`^\
jhfdb`^\ !
jhfdb`^\ !!
k
ki
kig
kige
kigec
kigeca
kigeca_
kigeca_]
kigeca_]
kigeca_] !
kigeca_] !!
l
lj
ljh
ljhe
ljhed
ljhedb
ljhedb`
ljhedb`^
ljhedb`^
ljhedb`^ !
ljhedb`^ !!
m
mk
mki
mkie
mkiee
mkieec
mkieeca
mkieeca_
mkieeca_
mkieeca_ !
mkieeca_ !!
n
nl
nlj
nlje
nljef
nljefd
nljefda
nljefda`
nljefda`
nljefda` !
nljefda` !!
o
om
omk
omke
omkeg
omkege
omkegea
omkegeaa
omkegeaa
omkegeaa !
omkegeaa !!
p
pn
pnl
pnle
pnleh
pnlehf
pnlehfa
pnlehfab
pnlehfab
pnlehfab !
pnlehfab !!
q
qo
qom
qome
qomei
qomeig
qomeiga
qomeigac
qomeigac
qomeigac !
qomeigac !!
r
rp
rpn
rpne
rpnej
rpnejh
rpnejha
rpnejhad
rpnejhad
rpnejhad !
rpnejhad !!
s
sq
sqo
sqoe
sqoek
sqoeki
sqoekia
sqoekiae
sqoekiae
sqoekiae !
sqoekiae !!
s
sr
srp
srpe
srpel
srpelj
srpelja
srpeljaf
srpeljaf
srpeljaf !
srpeljaf !!
s
ss
ssp
sspe
sspem
sspemk
sspemka
sspemkag
sspemkag
sspemkag !
sspemkag !!
s
st
stp
stpe
stpen
stpenl
stpenla
stpenlah
stpenlah
stpenlah !
stpenlah !!
s
su
sup
supe
supeo
supeom
supeoma
supeomai
supeomai
supeomai !
supeomai !!
s
su
sup
supe
supep
supepm
supepma
supepmaj
supepmaj
supepmaj !
supepmaj !!
s
su
sup
supe
supeq
supeqm
supeqma
supeqmak
supeqmak
supeqmak !
supeqmak !!
s
su
sup
supe
super
superm
superma
supermal
supermal
supermal !
supermal !!
s
su
sup
supe
super
superm
superma
supermam
supermam
supermam !
supermam !!
s
su
sup
supe
super
superm
superma
superman
superman
superman !
superman !!
s
su
sup
supe
super
superm
superma
superman
superman
superman !
superman !!