473,386 Members | 1,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

concatenating a string and a number in flash ?

Hi,

I wonder if anyone can help here ? I know this is a pretty simple thing - but Im just getting into actionscript and Im stuck on one part of something I am trying to do.

Basically and exmaple of what I am trying to do is - I have three text boxes, txt1,txt2,txt3. I then have another layer with some actionscript on, where I have a loop, and in that loop I have a string with the value 'txt'. I am trying to tag the value of the loop counter on the end of that string, and then use the concatenated result as a reference to populate the relevant txt box.

I cant seem to get it to work though, it does not recognise the number on the end of the string ?

Expand|Select|Wrap|Line Numbers
  1.  
  2. var str1 = "txt";
  3.  
  4. var i:Number = 4;
  5. while (i <5) {
  6.     var str2 = str1 + i;
  7.     eval(str2).text = "hello";
  8.     i++;
  9. }
  10.  
  11.  
  12.  
  13.  
  14.  
Any thoughts appreciated.

Thanks
May 9 '07 #1
1 2320
Have a look at your code. It would work fine if you had a dynamic text field on the stage named txt4.

Another way to reference the text field would be to use the array access operator ([]).

Expand|Select|Wrap|Line Numbers
  1. this[str2].text = "hello";
May 21 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

16
by: Dixie | last post by:
I have a problem using Dev Ashish's excellent module to concatenate the results of a field from several records into one record. I am using the code to concatenate certain awards onto a...
4
by: Juan | last post by:
Does any one know if there are reported bugs when concatenating strings? When debugging each variable has the correct value but when I try to concatenate them some values are missing (I canīt see...
4
by: FB's .NET Dev PC | last post by:
Interesting note, the code below as is will attempt to cast what is clearly indicated as a string into a double. This is becuase the use of + as a concatenation operator. The error message...
53
by: Jeff | last post by:
In the function below, can size ever be 0 (zero)? char *clc_strdup(const char * CLC_RESTRICT s) { size_t size; char *p; clc_assert_not_null(clc_strdup, s); size = strlen(s) + 1;
27
by: fuch6921 | last post by:
I want to read in an Octal number argument and have it stored as an octal number. For instance the user will type: ./a.out 777 and it will store the octal number 777. But it atoi does this as an...
14
by: Erik | last post by:
Hi, i'm trying to do this : #include <stdlib.h> #include <stdio.h> #define FILE "/tmp/myfile" #define USERS_LIST "/tmp/userslist" int main() { //open file
4
by: lindiwemaduna | last post by:
I want to concatenate values of two text boxes into one string but these should be separated by a space in the database table. i have tried all the following but twas not successful: Dim fullName...
232
by: robert maas, see http://tinyurl.com/uh3t | last post by:
I'm working on examples of programming in several languages, all (except PHP) running under CGI so that I can show both the source files and the actually running of the examples online. The first...
2
by: Whizzo | last post by:
Hi all; I'm using this great bit of code to concatenate a fields from multiple rows into a single one. 'Concat Returns lists of items which are within a grouped field Public Function...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.