View Full Version : Flash 8 UI Component Text Input ERROR!
anandkanatt
01-06-2007, 11:50 AM
Hi,
import mx.UIcontrols.*
var Pos:Object = new Object;
Pos.x = 18;
Pos.y = 18;
this.createObject("TextInput","ctiInput1",this.getNextHighestDepth());
this.createObject("TextInput","ctiInput2",this.getNextHighestDepth());
this.createObject("TextInput","ctiInput3",this.getNextHighestDepth());
this.createObject("Button","cbtResult",this.getNextHighestDepth());
ctiInput1.move(Pos.x,Pos.y);
ctiInput2.move(Pos.x,Pos.y+22);
ctiInput3.move(Pos.x,Pos.y+44);
cbtResult.move(Pos.x,Pos.y+66);
var oListener:Object = new Object;
cbtResult.addEventListener("click", oListener);
oListener.click = function (oEvent:Object):Void {
trace("Clicked"+this.ctiInput1.text+" || "+this.ctiInput2.text);
this.ctiInput3.text = this.ctiInput1.text + this.ctiInput2.text;
}
as a result of above code i get a display with 3 TextInputs and a Button. But the problem is when i click on the button i get the component text input's '.text' value as "undefined" pls help ..
ah i forgot i am using a "Form" to build this.
Regards
Anand
Mazoonist
01-06-2007, 03:46 PM
Your problem is coming from your use of the word "this" inside the event handler. In that case, "this" is referring to the listener object, and since that object has no objects inside it called ctiInput1, ctiInput2, and ctiInput3, you're getting "undefined" when you try to access their "text" properties. To fix it, take out the keyword "this" everywhere it occurs inside the event handler.
anandkanatt
01-08-2007, 11:40 AM
Your problem is coming from your use of the word "this" inside the event handler. In that case, "this" is referring to the listener object, and since that object has no objects inside it called ctiInput1, ctiInput2, and ctiInput3, you're getting "undefined" when you try to access their "text" properties. To fix it, take out the keyword "this" everywhere it occurs inside the event handler.
Thanks for that post. now i got it corrected.:)
anandkanatt
01-08-2007, 12:08 PM
Hi,
Im developing a project that involves a socket server between the flash app and the database. I am working using the "FORM" in Screen Type. There are two files in the project file 1 = main.fla, file 2 = frm_invitation_request.fla . The 1st file connects to the server and loads the second movie with the code var mclTrigger:MovieClipLoader = new MovieClipLoader();
var oListener:Object = new Object();
mclTrigger.addListener(oListener);
mclTrigger.loadClip("frm_invitation_request.swf", 3);
now my file 2 tries to access the connection variable connected to the server to send a query request. This file contains a form called frmRequest the following code has been entirely written on the onClip(load) of the form.
onClipEvent(load){
import mx.core.component.*;
//--------------<Tab Index>-----------------\\
ctiName.tabIndex = 1;
ctiEmail.tabIndex = 2;
cbtRequest.tabIndex = 3;
//--------------</Tab Index>-----------------\\
var ctiName:mx.controls.TextInput;
var ctiEmail:mx.controls.TextInput;
//--------------<Error Checking>-----------------\\
var oListener:Object = new Object();
oListener.click = function(oEvent:Object):Void {
if (ctiName.text != "" || ctiEmail.text != "") {
//if both fields contain text insert the data
var oReq:Object = new Object();
oReq.name = ctiName.text;
oReq.email = ctiEmail.text;
_level0.smartfox.sendXtMessage(extInvitationReques t, "putData", oReq, "xml");
} else {
clblStatus.text = "Please fill both fields";
}
};
//--------------</Error Checking>-----------------\\
// Adding the listener object to the component button
this.cbtRequest.addEventListener("click", oListener);
_level0.smartfox.onExtensionResponse = function(resObj:Object, type:String) {
// We expect the response to be xml formatted
if (type == "xml") {
// Let's check if it's a "getData" message
if (resObj._cmd == "putData" && resObj.ok == true) {
trace("Request Generated");
clblStatus.text = "Request is made to the administrator!";
} else {
trace("Error!, Please Re-try.");
clblStatus.text = "Error";
}
}
};
}
_level0.smartfox.sendXtMessage(extInvitationReques t, "putData", oReq, "xml"); this is the code that tries to connect with the server for a query. But my problem is that i am not able to send the query. i would like to know why i am not able to send the query. I am asking this because when i move my file 1's code to a regular movie (the old movie timeline without the FORM Screen type) i am able to connect from my 2nd file.
Please help ..
anandkanatt
01-08-2007, 01:39 PM
hi,
In the below said problem i got a breakthrough:
I am able to access the connection variable smartfox when i refer it at_level0.frmLoad.smartfox.sendXtMessage(extInvita tionRequest, "putData", oReq, "xml");
Can someone explain me why ?? is it because i have declared it in the frmLoad's onClipEvent(load) ?? Pls give me some pointers as i am not able to get into a conclusion.
Regards
Anand
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.