adding numbers to vairable names

  • zorrcell
  • Newbie
  • Newbie
  • zorrcell
  • Posts: 8

Post 3+ Months Ago

how do i add numbers to variable names:

Code: [ Select ]
 
 
for (i=0; i < this.resp; i++){
 
   topic[i] = this.topic[i];
 
}
 
 
  1.  
  2.  
  3. for (i=0; i < this.resp; i++){
  4.  
  5.    topic[i] = this.topic[i];
  6.  
  7. }
  8.  
  9.  


so i dont have to do this:

topic0 = this.topic0;
topic1 = this.topic1;
topic2 = this.topic2;
topic3 = this.topic3;
topic4 = this.topic4;

. again how do i do this?
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • SpooF
  • ٩๏̯͡๏۶
  • Bronze Member
  • User avatar
  • Posts: 3422
  • Loc: Richland, WA

Post 3+ Months Ago

Look into arrays

http://www.tizag.com/javascriptT/javascriptarray.php

Its practically what your code is doing right now.
  • zorrcell
  • Newbie
  • Newbie
  • zorrcell
  • Posts: 8

Post 3+ Months Ago

Code: [ Select ]
topic[i] = this.topic[i];


the first thing is the variable for a dynamic text
the second refers to the variable loaded from php (hence using this.)

and i just tried it it dint work, probably because the variable i loaded is just a string, it just returns &topic0= (w/e) &topic1= (w/e) &topic2= (w/e)

if ur still confused, its the same concept in php where you go:

Code: [ Select ]
print "topic$i";


edit:
i just looked at flash-forum/well-sit-down-make-cuppa-coffee-and-let-explain-t88885.html

but it says
Code: [ Select ]
this.["topic"+i];
is an error cuz it needs an oporator after the .

however ["topic"+i] is accepted ( not sure if it works though)

edit2:

i traced the variable thats oging into the flash from php and it works however the dynamix text variable is undefined:

Code: [ Select ]
["topic"+i] = _root.forumOut["topic"+i]

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 20 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.