Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0

Reply
 
Thread Tools Rate Thread Display Modes
Old 05-21-2012, 12:18 AM   #1
American horizon
Senior Member
 
Join Date: Jun 2011
Posts: 165
Default 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?
American horizon is offline   Reply With Quote
Old 05-21-2012, 04:51 AM   #2
Sonny
Senior Member
 
Join Date: Aug 2010
Location: Sydney,Australia
Posts: 132
Default 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
Sonny is offline   Reply With Quote
Old 05-21-2012, 07:23 AM   #3
Poony
Senior Member
 
Poony's Avatar
 
Join Date: Aug 2011
Location: Sweden
Posts: 387
Default

Quote:
Originally Posted by Sonny View Post
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
ActionScript Code:
invite.tf.text

Seems to me that you are over-complicating things.
Poony is offline   Reply With Quote
Old 05-21-2012, 02:36 PM   #4
American horizon
Senior Member
 
Join Date: Jun 2011
Posts: 165
Default

Quote:
Originally Posted by Poony View Post
Dont use the name property on dynamically created objects, use the assigned variable name instead.. In this case "tf".

Example
ActionScript Code:
invite.tf.text

Seems to me that you are over-complicating things.
i don't understand.
American horizon is offline   Reply With Quote
Old 05-21-2012, 03:42 PM   #5
[afz]snickelfitz
Senior Member
 
[afz]snickelfitz's Avatar
 
Join Date: Dec 2011
Location: Tucson, AZ
Posts: 2,332
Default

ActionScript Code:
trace(invite.address.text);
[afz]snickelfitz is offline   Reply With Quote
Old 05-21-2012, 04:20 PM   #6
American horizon
Senior Member
 
Join Date: Jun 2011
Posts: 165
Default

Quote:
Originally Posted by [afz]snickelfitz View Post
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.
American horizon is offline   Reply With Quote
Old 05-21-2012, 06:05 PM   #7
[afz]snickelfitz
Senior Member
 
[afz]snickelfitz's Avatar
 
Join Date: Dec 2011
Location: Tucson, AZ
Posts: 2,332
Default

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.
[afz]snickelfitz is offline   Reply With Quote
Old 05-21-2012, 06:14 PM   #8
American horizon
Senior Member
 
Join Date: Jun 2011
Posts: 165
Default

Quote:
Originally Posted by [afz]snickelfitz View Post
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 */ }
American horizon is offline   Reply With Quote
Old 05-21-2012, 07:19 PM   #9
[afz]snickelfitz
Senior Member
 
[afz]snickelfitz's Avatar
 
Join Date: Dec 2011
Location: Tucson, AZ
Posts: 2,332
Default

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.
[afz]snickelfitz is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:42 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.