it leader

FOCUS_IN , FOCUS_OUT  명령어

 

아이디와 비밀번호를 입력 받는 텍스트 필드 예제

 

기능1

- 텍스트 빌드에 입력전에 아이디, 비번이라는 안내 문구 출력

- 커서를 위치 시키면 안내문구가 사라지는 기능

- 글자를 하나라도 입력 하였을 떄 안내 문구가 사라지지 않게 하는 기능

- 텍스트필드에 커서 위치시 텍스트 필드의 색이 바뀌는 기능

- 비밀번호는 *로 표기하기

 

기능2

- 아이디와 비번 입력 받기

 

var id:TextField = id_txt;

var pw:TextField - pw_txt;

 

id.text="아이디";

pw.text="비밀번호";

 

id.addEventListener( FocusEvent.Focus_In, OnIdFocusIn);

 

function onIdFocusIn ( e: FocusEvent ) :void

{

 

id.border = true;    

id.borderColor = 0x009900;

id.background = true;

id.backgroundColor=0xFAFAD2;

 

if( id.text == "아이디")           //아이디라고 쓰여져 있을 때 텍스트 필드 날리기

{

id.text="";

 

}

 

}

 

id.addEventListener ( FocusEvent.FOCUS_OUT, onIdFocusOut);

 

function onIdFocusOut ( e: FocusEvent ) : void

{

id.border = true;

id.borderColor = 0x000000;

id.background = true;

id.backgroundColor=0xffffff;

 

if( id.text == "";)                   //텍스트 필드에 아무것도 없을 때 아이디라고 입력해 주기

{

 

id.text = "아이디";

 

}

 

}

 

pw.addEventListener( FocusEvent.FOCUS_IN, onPwFocusIn);

 

function onPwFocusIn ( e: FocusEvent ) : void

{

pw.border = true;

pw.borderColor = 0x009900;

pw.background = true;

pw.backgroundColor=0xFAFAD2;

 

 

pw.displayAsPassword = true ;       //텍스트를 패스워드문구 "*"로 표시하기

 

 

if( pw.text == "비밀번호")

{

pw.text = "";

}

 

}

 

 

 

pw.addEventListener( FocusEvent.FOCUS_OUT, onPwFocusOut);

 

function onPwFocusOut( e: FocusEvent): void

{

pw.border = true;

pw.borderColor = 0x000000;

pw.background = true;

pw.backgroundColor=0xffffff;

 

pw.displayAsPassword= true;

 

if( pw.text == "";)

{

pw.text=="비밀번호";

}

 

}

 

profile

it leader

@dev__pixui

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!