Professional :: Reference A Text Field With A Variable?

May 7, 2011

I have 10 text fields named "text1", "text2" etc;

I'd like to use a for loop to pulate each one, so that each text filed is populated with whatever i is:

for (var i:Number=1; i<=10;i++)  {
"team"+i.text = i;
}

I keep getting errors with regards to how the text filed name is referenced.

What is the correct way to increment the text filed name and reference it?
 
I've tried:

["team"+i].text = i;
"team"[i].text = i;

but they don't work.

View 1 Replies


Similar Posts:


Professional :: Text Added To Text Field Using Variable Doesn't Appear

Oct 4, 2010

I have a test field that I've created dynamically.  If I add text to it by writing: myField.text = "some text"  the text appears, but if I add text using a variable I don't see anything.  If I trace the text field's text trace("text = " myField.text) I get the right value.

View 6 Replies

ActionScript 2.0 :: Calculator - Clear The Text Field Then Store The New Input In The Same Text Field As A Different Variable

Mar 30, 2006

I'm making a calculator using Flash MX that works the same way as the basic calculator found on windows (not the scientific one). But having the user input a number, store it as a variable, store which function the user wants to perform and clear the text field then store the new input in the same text field as a different variable and multiply or add or divide or subtract the 2 numbers and getting the equals sign to display the answer when clicked is harder than I thought it would be.

View 3 Replies

ActionScript 2.0 :: Reference The Variable Pointed To By The Variable Text Cont?

May 25, 2010

How do I reference the variable pointed to by the variable text but pointed to by more than one function?Say I have:

engine_level = 5;
tank_level = 3;
v_name = 'engine';

[code].....

View 4 Replies

ActionScript 2.0 :: Reference The Variable Pointed To By The Variable Text?

Jan 5, 2012

How do I reference the variable pointed to by the variable text?

Say I have:

engine_level = 5;
v_name = 'engine';
pb_name = v_name + '_p_button'; // so pb_name = 'engine_p_button';
level = v_name + '_level'; // so level = 'engine_level';

[Code]......

View 2 Replies

Professional :: Pass The Contents Of The Text Field To Another Text Field?

Nov 8, 2010

I've created a dynamic text field - mediaImportName001 (created , and populated it with the name of a file that I choose to import using a browse button (as3 and AIR).This works fine - I can import the file, and the name appears in the field.
 
I'd now like to pass the contents of the text field to another text field.  But I can't get the contents. If I try to trace the contents of the textField trace("mediaImportName"+thisNum).text     - Flash returns "undefined" (even though I'm asking it to trace after the field has been populated).
 
I use the following code to check that the field really is there and named correctly (the code returns the children):
 
for (var i:uint = 0; i < this.numChildren; i++){    trace (this.getChildAt(i).name + ' type:' + typeof (this.getChildAt(i))+ ' ' + this.getChildAt(i));}
 
it returns:
 
instance370     type:object    [object Shape]mediaImportName001     type:object    [object TextField]mediaFiletype001     type:object    [object TextField]
 
How do I get Flash to give me the text in mediaImportName001?  
 
It's bizarre - this.getChildAt(i).name
 
from above gives me...
 
mediaImportName001     ,
 
yet
trace (["mediaImportName"+thisNum].name); 
 
returns undefined (thisNum represents an increment I use to name multiple clips and text fields, and in this case trace(thisNum); returns 001)

View 4 Replies

Reference Text With Variable?

Oct 20, 2009

I want to be able to reference the text of a text box within an MCThe MC is called "box1", the text field is called "field1"...I have many MCs (all with field1 in them)... box1, box2, box3 etc etcObviously I can set the text to being something by saying...box1.field1.text = "set_this_text"However, I'm using a variable to come up with the "box1" bit. (Using an array and a loop to figure out which box I want to update based on where the user clicked). So, let's say I have a variable... and I want to say..boxClickedon = box1 //will be defined by userSo I don't know in advance about box1... I can only access it through "boxClickedin" variable, but

boxClickedin.field1.text = "set_this_text"
or
[boxClickedin].field1.text = "set_this_text"

[code]....

View 1 Replies

ActionScript 2.0 :: Loading Text Variable To Dynamic Text Field?

Jul 10, 2009

Go into the 3D Studio Max link and in there you'll see my problem.....How can I get the text to format to the width of the dynamic text field? What I have are variables set up to load text from an uploaded .txt file, into the dynamic text field... it seems to run each line way over to the right...

View 3 Replies

ActionScript 3.0 :: Displaying Variable As Text In Dynamic Text Field?

May 24, 2010

This should be basic enough but I'm having trouble troubleshooting it

var instrument:MovieClip=banjo;
instrument_txt.text="The " + String(instrument)+ " has been selected!";

I wanted this to result in dynamic text field displaying

"The banjo has been selected!" but it results in "The [Object MovieClip] has been selected!".

Is String(var) wrong command to use? The only reason I could think why it's not working is, that the variable has been stated as 'MovieClip' instead of Number or Text. What can be done in the case of MovieClip if this is correct?

P.S I'm wondering if there're rules on asking questions on this board... I've asked two for today already and they would be considered pretty 'basic' ones to professionals / experienced users on this board >_<

View 2 Replies

ActionScript 3.0 :: Use Of A Variable To Reference A Text Box In An Instance?

Aug 16, 2009

Lets say I have 3 Movie Clip Symbols in  my Library : Movie0, Movie1 and Movie2
 
Each movie has a dynamic text box: "TextBox1"
 
I want to be able to write a function that can manipulate the alpha(or any attribute) of the TextBox1 in all three MovieClips.

In my limited experience I thought I could do something like the following:

for (var row:int = 0; row < dataArray.length; row++)
{
Movie(row).TextBox1.alpha = 1;
}
 
I hoped that this would loop through 3 times and set the alpha of the TextBox1 in all three movies to 1.
 
Is this possible? Can you reference an instance with use of a variable?

View 2 Replies

ActionScript 3.0 :: Use A Variable(text) To Reference A Movieclips Instance Name?

Nov 28, 2010

i want to use a variable(text) to refrence a movieclips instance name

Code:
function InventoryShow(event:Event):void
{
var SC:URLVariables = new URLVariables(event.target.data);

[Code].....

View 1 Replies

ActionScript 3.0 :: Get Variable And Display In Text Field?

May 4, 2009

I want to put a texfield on stage and then refrence a variable and display its value...the trick is the value i want to refrence is in an external .as file not within the document class .....so how do i put a text field on stage and then access variable rec1 from the following code.

PHP Code:
package NetConnections.Send{
public class Send {

[code]....

View 13 Replies

ActionScript 3.0 :: Passing A Variable To Text Field?

Feb 5, 2011

I need to create an action script function so that when a mc is pressed, it sends a variable that is in it (letter_rdm)to a dynamic text field at the bottom. Heres my code:

function placeALetter(e:Event):void{
var tmp:mcLetter = new mcLetter();
tmp.width = 100;
tmp.height = 100;

[Code]....

View 6 Replies

AS3 :: Flash - Display A Variable In A Text Field?

Nov 22, 2010

I have been creating myself mini-projects to learn and my newest one is to have a variable that counts up.

for (var i = 0; i < 0; i++)
{
trace (i);
}

I have a dynamic text field that I am trying to display the variable i in a dynac text field. How would I do this?

View 1 Replies

ActionScript 3.0 :: Load Php Variable In Text Field?

Dec 11, 2010

I'm trying to make the day flash send the variables to a text field with as3.

[Code]...

View 1 Replies

ActionScript 2.0 :: Create A String Then Use It To Reference A Variable In An External Text File

Jan 19, 2011

So i have an external text file organized like this:

/* $file: data.txt */
&title0=Sacrum
&detail0=Detail text for Sacrum
&title1=L5

[Code].....

There are 28 of these 'title' and 'detail' pairs. The 'title' text is to fill a dynamic text box and the 'detail' to fill another dynamic text box depending on which section the user is mousing over.

My issue is getting the text from the file stored into arrays. For my test loop I keep getting undefined as the stored value, and i know it has something to do with converting a string value to object..

var lv:LoadVars = new LoadVars();
lv.onLoad = handleDataLoad;
lv.load('data.txt');
function handleDataLoad (success:Boolean) {

[Code]....

View 1 Replies

Load String From Dynamic Text Field As Variable?

Oct 7, 2009

I am trying to grab a string that is loaded into my dynamic text field and use it as a variable.

The text field is populated when another button is pressed first which says input_txt.text = "myInput"

...I gave my dynamic text field the instance name input_txt

So I wrote out (on a separate button):

on (release) {
var input:String = input_txt;
trace(input);
}

I get "undefined" as my output

View 1 Replies

ActionScript 3.0 :: Dynamic Text Field - Variable Height?

Nov 2, 2008

Is there a way to adjust the height of a variable text fieldto match the dynamic content populated at run-time?I have a dynamic text field on the stage. I replace the copyin that field at run-time and it may be 1, 2, 3, or 4 lines long ifthe width of the text field stays the same. Is there a way tocontrol the height of the control to adjust to support only thenumber of lines needed? I'd like to set another control on thestage right below this field but I need the correct height of the

View 1 Replies

ActionScript 3.0 :: Simple Text Field Displaying Variable ?

Jun 7, 2009

in a simple AS2 .fla there was a text field labeled "message_number" which would display the variable "message_number."  Very straightforward.How can a text field in AS3 be made to display this variable?

View 7 Replies

ActionScript 3.0 :: Text Field Variable Names Are Not Supported

Jan 26, 2010

So my website was created in FLash CS4 which is AS3. I did a tutorial online recently to create scrollbar for dynamic text; but sadly I didn't realize the code I had copied was AS2! I tried to import the scrollbar.swf into my website and it gave me this message:Text field variable names are not supported in ActionScript 3.0. The variable 'txt' used for the text field 'txtBox' will not be exported.[code]

View 8 Replies

ActionScript 2.0 :: Function Not Updating Text Field & Variable

Jan 12, 2009

I have a function that is suppose to update a variable which updates a textfield and it is not working.

[Code]...

View 0 Replies

ActionScript 3.0 :: Display A Variable In A Dynamic Text Field?

Dec 11, 2009

How do you display a variable in a dynamic text field? (OOP)

View 0 Replies

ActionScript 3.0 :: Show Variable In A Dynamic Text Field?

Dec 11, 2009

how do you display a variable in a dynamic text field?

View 2 Replies

ActionScript 3.0 :: Display Variable In Dynamic Text Field?

Oct 9, 2010

I have a timer that counts up to 60.

Within the timer function I have a variable that increments every second,

i.e second = second +1; I'm tracing that out and it counts up nicely on the trace output.

I want to add what I'm tracing to a text field on my stage so a text box will display the counting from 1 to 60.[code]...

View 9 Replies

Actionscript 3.0 :: Assign A Variable To A Dynamic Text Field?

Jan 13, 2009

I want to assign a variable "speed" to a dynamic text field with the instance "spdDisplay" and round it to two decimal places.I'm pretty new to flash but, this seems like it should be easy.Here is the code I have - it does not work

Code: Select allvar speed:Number = angle/2.1;
trace(speed.toFixed(2));
spdDisplay.text = (speed);

[code].....

View 2 Replies

ActionScript 2.0 :: Why Can't Set A Dynamic Text Field Equal To A Variable

Jul 26, 2004

I have a preloader. On one frame of the preloader is the code:

i++
loadtext = i;
emptyMC = "holder"+i
allimages._visible = false;
allimages.createEmptyMovieClip("holder"+i, i);
allimages[emptyMC].loadMovie("weddingsintro"+i+".jpg");

Everything works fine, but the dynamic textfield with the var name loadtext is blank. If i set loadtext = i+"loaded" then it just displays "loaded". I know the variable "i" has a value since the rest of the preloader works.

View 4 Replies

ActionScript 2.0 :: Loading Value Of A Variable Into Dynamic Text Field

Feb 20, 2007

I have a variable that changes according to the position of a slider. I would like to display the numerical value of this variable inside a dynamic text field (created on the stage during authoring).I tried many approaches, but the one I was sure would work didn't. I referenced the "text" value of the dynamic text field from the frame in which the variable was instantiated and used. This did not work, so I am not sure what to do.[code]

View 4 Replies

ActionScript 2.0 :: Inserting A Variable Into A Dynamic Text Field?

Mar 6, 2007

I know you can read the contents of a text file into a dynamic text field at runtime. Can you also insert the string contents of a variable into a dynamic text field at runtime? I simply want a dynamic text field that says "Welcome back, <username>" I am doing it right now with a static text field and a dynamic one, but if the username is really short, the whole thing is not centered and looks weird. Optimally, it should all be part of one element on the stage.

View 9 Replies

ActionScript 2.0 :: Increasing Variable For Dynamic Text Field?

May 9, 2008

I'm trying to create a temperature control box for a flash movie and i have it so that two arrows would control the temp, i can't seem to get them to increase the dynamic text field titled target_temp it sets it fine on the first load but then once I try to click the increase arrow the text field doesn't increase, do i need to reload the movie? here is the code I have so far.

Code:
on(release){
target=target-1;
target_temp.text=target;
}

View 1 Replies

ActionScript 2.0 :: Can't Set Dynamic Text Field Equal To A Variable?

Jul 26, 2004

I have a preloader. On one frame of the preloader is the code:[code]Everything works fine, but the dynamic textfield with the var name loadtext is blank. If i set loadtext = i+"loaded" then it just displays "loaded". I know the variable "i" has a value since the rest of the preloader works. Anyone know whats wrong?

View 4 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved