flash actionscript:
I've seen this asked a couple dozen times in various places, but have never
seen an answer.
I start the app, then click a button that calls my premade form with this:
createEmptyMovieClip("register1_mc", 20002);
register1_mc.attachMovie("register_mc", "register2_mc", level, {_x:150,
_y:50});
The form/movie has Profile as it's AS2.0 class.
Then it get bizarre.
Here's my output with notes:
txtFirst_Name.text #1 : undefined // Not yet available in the constructor
sText : ABC123 // Everything thing looks great here when I call this via the
doLater function. I set and get the .text for my TextInput
txtFirst_Name.text #2 : ABC123 //This value also shows up in the TextInput on
the screen
fillinfo : undefined //These 2 lines generated when I enter 2 characters in my
TextInput. The change event listener works great for my TextInput
fillinfo : undefined // But it can't find it's own .text value. It is not
undefined, it right there on my screen with ABC123 in it!?!?
Register // When I click my Register button it still cannot find the .text of
my TextInput
txtFirst_Name.text #3 undefined
Also, why does this function not get called from within my Register function?
this.FillText();
import mx.core.UIObject;
import mx.controls.Button;
import mx.controls.TextInput;
class Profile extends UIObject {
private var txtFirst_Name:TextInput;
private var txtLast_Name:TextInput;
private var but_register:Button;
private var cancel1_btn:Button;
private var txtAst1:TextField;
private var keyListener:Object = new Object();
private var _sAddUpdate:String;
private var dispatchEvent:Function;
public var addEventListener:Function;
public var removeEventListener:Function;
function Profile() {
Selection.setFocus("txtFirst_Name");
doLater(this, "addListeners");
doLater(this, "FillText");
}
function Enter() {
switch (Key.getCode()) {
case Key.ENTER :
Register();
break;
}
};
function addListeners() {
but_register.addEventListener("click", Register);
cancel1_btn.addEventListener("click", Cancel);
txtFirst_Name.addEventListener("change",fillInfo)
}
function fillInfo() {
trace("fillinfo : " + this.txtFirst_Name.text);
}
function updateProfile(x:Number) {
trace("UPDATE " + x);
}
function Cancel() {
Key.removeListener(keyListener);
unloadMovie(this._parent);
unloadMovie(this);
};
function Register() {
trace("Register");
this.FillText();
txtFirst_Name.text = "ABCDEFG";
trace("txtFirst_Name.text" + txtFirst_Name.text);
if (txtFirst_Name.text == "") {
mx.controls.Alert.show("Please Enter First Name");
Selection.setFocus("txtFirst_Name");
}
else if (txtLast_Name.text == "") {
mx.controls.Alert.show("Please Enter Last Name");
Selection.setFocus("txtLast_Name");
}
else {
//Register Code
}
}
function FillText() {
var sText:String;
sText = "ABC123";
trace("sText : " + sText);
txtFirst_Name.text = sText;
trace("txtFirst_Name.text : " + txtFirst_Name.text);
}
function SetTabs() {
txtFirst_Name.tabIndex = 1;
txtLast_Name.tabIndex = 2;
but_register.tabIndex = 3;
cancel1_btn.tabIndex = 4;
}
}