views:

529

answers:

3

Hi Everybody, I have a doubt in flash AS3, my requirement is how to place a watermark in Flash Input text field so that if any user clicks on the input text field then the text which was already appearing should not be visible . I hope that i will get a better answers from anyone of you Thanks --Jennifer.

+1  A: 

The term you're actually looking for is called cuebanner, not watermark. I'm not familiar with Flash, so I can't tell you how to do it. But if you Google cuebanner, you may get better information than when googling for watermark.

dustyburwell
A: 

yes you can do that like this create a text file enter the text addEventListener that listen to the CLICK of the user and in the function clear the content of the text Field

txt = new TextField();
txt.text = "clikc me";
txt.addEventListener(MouseEvent.CLICK,onTxtClick);
this.addChild(txt);

// the Listen function
private  function onTxtClick(evt:MouseEvent):void
{
     txt.text = "";
}
Shvilam
Thanks Shvilam ---Jenny
thanks it nice but a few point will be even nicer
Shvilam
+1  A: 

To improve slightly what Shvilam wrote:

public static const PROMPT:String = "Type your text here...";
public static const PROMPT_COLOR:Number = 0x999999;

txt = new TextField();
txt.text = PROMPT;
txt.textColor = PROMPT_COLOR;
txt.addEventListener(FocusEvent.FOCUS_IN, focusHandler);
txt.addEventListener(FocusEvent.FOCUS_OUT, focusHandler);
this.addChild(txt);

// the Listen function
private  function focusHandler(event:FocusEvent):void
{
     switch (event.type) {
     case FocusEvent.FOCUS_IN:
         if (txt.text == PROMPT) {
            txt.text = "";
            txt.textColor = 0xFFFFFF;
         }
         break;
     case FocusEvent.FOCUS_OUT:
         if (txt.text == "") {
             txt.text = PROMPT;
             txt.textColor = PROMPT_COLOR;
         }
         break;
}

(Untested.)

David Hanak