# EVAL to apply text variables

**URL:** <https://forum.kirupa.com/t/eval-to-apply-text-variables/26119>\
**Category:** flash\
**Created:** [July 19, 2003, 8:19pm UTC](https://forum.kirupa.com/t/eval-to-apply-text-variables/26119 "2003-07-19T20:19:17Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![davec](https://avatars.discourse-cdn.com/v4/letter/d/a4c791/32.png) [@davec](https://forum.kirupa.com/u/davec)\
**Post date:** [July 19, 2003, 8:19pm UTC](https://forum.kirupa.com/t/eval-to-apply-text-variables/26119/1 "2003-07-19T20:19:17Z")

</div>

Hi,

I have a clip containing 8 MCs, named id1, id2 etc, each of which contain a dynamic text field with the variable thisNo. I want to run a loop that inserts each digit from a randomly generated number into each of these MCs

PatID is the random number, IDLength is it’s character length.

for (i=1; i\<(IDLength+1); i++) {  
thisNo = PatID.substr(-i,1);  
eval(“id”+i).iconNo = thisNo;  
}

…but it don’t work.

Help!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 19, 2003, 8:37pm UTC](https://forum.kirupa.com/t/eval-to-apply-text-variables/26119/2 "2003-07-19T20:37:48Z")

</div>

you’re mixing numbers and strings here,  
if PatID is a rand N°, you shouldn’t be using string methods on it,  
and IDLength is used in your loop, but where is it assigned the value?? (IDLength=PatID.\_length)? you don’t even need that, if you want to use the string methods, try i\<PatID.toString.\_length… something like that…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 19, 2003, 8:44pm UTC](https://forum.kirupa.com/t/eval-to-apply-text-variables/26119/3 "2003-07-19T20:44:45Z")

</div>

Here’s a quick’n’dirty fla…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 19, 2003, 9:21pm UTC](https://forum.kirupa.com/t/eval-to-apply-text-variables/26119/4 "2003-07-19T21:21:58Z")

</div>

🙂 Thanks Joe, you’re a star!

(I was converting the random number to a string first BTW.)

Cheers,

Dave

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 19, 2003, 10:41pm UTC](https://forum.kirupa.com/t/eval-to-apply-text-variables/26119/5 "2003-07-19T22:41:44Z")

</div>

This thread also helped me out.  
Thankx.

:thumb:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 19, 2003, 10:58pm UTC](https://forum.kirupa.com/t/eval-to-apply-text-variables/26119/6 "2003-07-19T22:58:43Z")

</div>

cheers then, m8, glad to help

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 20, 2003, 11:08am UTC](https://forum.kirupa.com/t/eval-to-apply-text-variables/26119/7 "2003-07-20T11:08:41Z")

</div>

> \*Originally posted by eyezberg \*  
> \*\*Here’s a quick’n’dirty fla… \*\*

One question though - you used

**\_root** [“id”+i].iconNo = thisNo;

Although my clips were on the same level, they weren’t on the root as per your example. I had to move the target MCs up a level as **this** wouldn’t work, but **\_parent** would.

Why is that?

Thanks,

Dave
