Skip to content

AS3 Focus

Just a really quick bit of code that hides “dummy” when textBox “txt” is clicked on.

I’m just posting this because I feel like I need to have more code related postings.

// set focus
txt.addEventListener(FocusEvent.FOCUS_IN, hideDummy );
txt.addEventListener(FocusEvent.FOCUS_OUT,showDummy );

function hideDummy( e:Event )
{
	dummy.visible = false;
}

function showDummy( e:Event )
{
	if( txt.length == 0 ) dummy.visible = true;
}

And in AS 2:

txt.onSetFocus = function( oldFocus ) : Void
{
     dummy._visible = false;
}

txt.onKillFocus = function( newFocus )
{
  if (txt.length < 3)
  {
      dummy._visible = true; TF_question.text = "";
  }
};

One Comment

  1. sharedtut wrote:

    thank you, ive been looking for a way to hide an object

    Thursday, January 21, 2010 at 7:47 PM | Permalink

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*