05-21-2012, 12:18 AM
|
#1
|
|
Senior Member
Join Date: Jun 2011
Posts: 165
|
Error #1123 when attempt to read the "text" propriety of a textfield created runtime
Hi
I have this code:
ActionScript Code:
trace ((getChildByName("invite") as MovieClip).(getChildByName("address") as TextField).text)
"invite" is a MovieClip created in runtime and i need to read the text that the user had inserted into the child named "address"
But flash retrieve me error #1123 Filter operator not supported on type "invite"
why?
|
|
|
05-21-2012, 04:51 AM
|
#2
|
|
Senior Member
Join Date: Aug 2010
Location: Sydney,Australia
Posts: 132
|
Error #1123 when attempt to read the "text" propriety of a textfield created runtime
Im not sure if I understood it right . But hope this snippet helps ...
Posting a bit more code or a bit more information could help narrowing down the issue
Cheers
Sonny
Quote:
import flash.display.MovieClip;
import flash.text.TextField;
import flash.events.Event;
var container:MovieClip = new MovieClip();
container.name = "empty_mc";
stage.addChild(container);
var tf:TextField = new TextField();
tf.name = "txtFld";
tf.type = "input";
tf.text = "someRandomText";
tf.addEventListener(Event.CHANGE,handleTextEvent,f alse,0,true);
container.addChild(tf);
function handleTextEvent(e:Event){
trace(container.getChildByName("txtFld") + " - " + (container.getChildByName("txtFld") as TextField).text );
//Prints [object TextField] - I have changed
}
trace(container+ " - " + container.name);
//Prints [object MovieClip] - empty_mc
trace(container.getChildByName("txtFld") + " - " + (container.getChildByName("txtFld") as TextField).text );
//Prints [object TextField] - someRandomText
|
Last edited by Sonny; 05-21-2012 at 04:59 AM.
Reason: Sorry my editing messed up last time
|
|
|
05-21-2012, 07:23 AM
|
#3
|
|
Flash Developer
Join Date: Aug 2011
Location: Sweden
Posts: 366
|
Quote:
Originally Posted by Sonny
ActionScript Code:
var tf:TextField = new TextField();
tf.name = "txtFld";
|
Dont use the name property on dynamically created objects, use the assigned variable name instead.. In this case "tf".
Example
Seems to me that you are over-complicating things.
|
|
|
05-21-2012, 02:36 PM
|
#4
|
|
Senior Member
Join Date: Jun 2011
Posts: 165
|
Quote:
Originally Posted by Poony
Dont use the name property on dynamically created objects, use the assigned variable name instead.. In this case "tf".
Example
Seems to me that you are over-complicating things.
|
i don't understand.
|
|
|
05-21-2012, 03:42 PM
|
#5
|
|
Senior Member
Join Date: Dec 2011
Location: Tucson, AZ
Posts: 1,888
|
ActionScript Code:
trace(invite.address.text);
|
|
|
05-21-2012, 04:20 PM
|
#6
|
|
Senior Member
Join Date: Jun 2011
Posts: 165
|
Quote:
Originally Posted by [afz]snickelfitz
ActionScript Code:
trace(invite.address.text);
|
eheh it's simple but you can do that only within the function where you declare the "invite" object..
if you need to call it in another function, writing
ActionScript Code:
trace(invite.address.text);
produce a "not found object" (error 1120) result when attempting to launch the swf
Last edited by American horizon; 05-21-2012 at 04:24 PM.
|
|
|
05-21-2012, 06:05 PM
|
#7
|
|
Senior Member
Join Date: Dec 2011
Location: Tucson, AZ
Posts: 1,888
|
Seems like the problem is related to the code or project structure, not the call to the invite object per se.
ie: pass the value into a function, provide setter/getter for the textfield value, dispatch an event when the field is updated, or some other AS3 solution.
Hard to say without some additional context.
|
|
|
05-21-2012, 06:14 PM
|
#8
|
|
Senior Member
Join Date: Jun 2011
Posts: 165
|
Quote:
Originally Posted by [afz]snickelfitz
Seems like the problem is related to the code or project structure, not the call to the invite object per se.
ie: pass the value into a function, provide setter/getter for the textfield value, dispatch an event when the field is updated, or some other AS3 solution.
Hard to say without some additional context.
|
ok this is the full context
ActionScript Code:
mail.addEventListener(MouseEvent.CLICK, function()
{
var inviteuser:invite=new invite()
addChild(inviteuser)
inviteuser.name="invite"
inviteuser.x=stage.stageWidth/2
inviteuser.y=300
inviteuser.sendbtn.addEventListener(MouseEvent.CLICK, sendinvite)
}
function sendinvite(e:Event):void
{
[....]
varsToPHP.dir=(getChildByName("invite") as MovieClip).getChildByName("address").text
/* i tryied too
varsToPHP.dir=(getChildByName("invite") as MovieClip).(getChildByName("address") as TextField).text
*/
}
|
|
|
05-21-2012, 07:19 PM
|
#9
|
|
Senior Member
Join Date: Dec 2011
Location: Tucson, AZ
Posts: 1,888
|
the .name property is not often used for dynamically instantiated objects.
The variable name is preferred.
Declare a variable or class property to store a reference to the invite instance.
This will allow other functions/methods to access it.
BTW, class names should begin with a Capital letter for better code clarity.
Also, it seems like the Invite class could contain all of the relevant code.
This would give you direct access to the send button and textfield.text values.
|
|
|
| Thread Tools |
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT. The time now is 12:13 AM.
///
|
|