ClearTextFieldLoop Actionscript
Table of contents | Previous document | Download ClearTextFieldLoop.as | SWF!T Homepage RCSfile: ClearTextFieldLoop.as,v Revision: 1.13 Date: 2003/01/29 16:40:19
Copyright 2003 Orgdot AS. All Rights Reserved. http://dev.swfit.com
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
This loop sets an input text field with an initial value, and clears the field once the user starts typing.
Two vars need to be set before the script is embedded: (which_textfield) and (which_textfield + "text_start"): Example: which_textfield = "display"; display_text_start = "type here to test drive fonts";
author Olaf Havnes
version Revision: 1.13 Date: 2003/01/29 16:40:19
since SWFIT1.0
flags
CLEARED = "cleared";
SET = "set";
do this until the field has been cleared
if ( eval (which_textfield add "_cleared") ne CLEARED )
{
text_start = eval (which_textfield add "_text_start");
do this once
if ( eval (which_textfield add "_set") ne SET )
{
set (which_textfield add "_text", text_start);
set (which_textfield add "_set", SET)
}
check for changes, and clear the field
text_now = eval (which_textfield add "_text");
if (text_start ne text_now)
{
if (length (text_now) > length (text_start))
{
did the user add something ?
(we assume that the user only had time to add a single character)
set (which_textfield add "_text", substring (text_now, length(text_now), 1));
set (which_textfield add "_cleared", CLEARED)
}
else if (length (text_now) < length (text_start))
{
did the user subtract something ?
(we assume that the user only had time for a single delete)
set (which_textfield add "_text", "");
set (which_textfield add "_cleared", CLEARED)
}
}
}
|
|