home *** CD-ROM | disk | FTP | other *** search
- package asCode
- {
- import flash.display.MovieClip;
- import flash.events.FocusEvent;
- import flash.text.TextField;
-
- public class STFinputFieldClass extends MovieClip
- {
- public static const SELECTED:String = "SELECT";
-
- public var textBoxBack:MovieClip;
-
- public var textBox:TextField;
-
- private var typeOfTextField:String;
-
- private var errorTriggered:Boolean;
-
- private var defaultText:String;
-
- private var textContent:String;
-
- public function STFinputFieldClass()
- {
- super();
- }
-
- public function initField(param1:String, param2:String = "text") : void
- {
- typeOfTextField = param2;
- defaultText = textBox.text = param1;
- errorTriggered = false;
- textBox.addEventListener(FocusEvent.FOCUS_IN,textboxSelected,false,0,true);
- textBox.addEventListener(FocusEvent.FOCUS_OUT,textboxDeselected,false,0,true);
- }
-
- public function testForContent() : Boolean
- {
- var _loc1_:int = 0;
- var _loc2_:int = 0;
- textContent = textBox.text;
- if(textContent == "" || textContent == defaultText)
- {
- textBox.text = defaultText;
- textBoxBack.gotoAndPlay("error");
- errorTriggered = true;
- return false;
- }
- if(typeOfTextField == "email")
- {
- _loc1_ = int(textContent.indexOf("@"));
- _loc2_ = int(textContent.indexOf("."));
- if(_loc1_ > 1 && _loc2_ > 1)
- {
- return true;
- }
- textBoxBack.gotoAndPlay("error");
- errorTriggered = true;
- return false;
- }
- return true;
- }
-
- public function reset() : void
- {
- textBoxBack.gotoAndPlay("reset");
- }
-
- public function textboxDeselected(param1:FocusEvent) : void
- {
- if(textBox.text == "")
- {
- textBox.text = defaultText;
- }
- }
-
- public function textboxSelected(param1:FocusEvent) : void
- {
- if(textBox.text == defaultText)
- {
- textBox.text = "";
- }
- if(errorTriggered)
- {
- errorTriggered = false;
- textBoxBack.gotoAndPlay("reset");
- }
- }
- }
- }
-
-