# taking contet from text field

**URL:** <https://forum.kirupa.com/t/taking-contet-from-text-field/636058>\
**Category:** programming\
**Created:** [February 21, 2017, 2:32pm UTC](https://forum.kirupa.com/t/taking-contet-from-text-field/636058 "2017-02-21T14:32:22Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![erezb1](https://avatars.discourse-cdn.com/v4/letter/e/ebca7d/32.png) [@erezb1](https://forum.kirupa.com/u/erezb1)\
**Post date:** [February 21, 2017, 2:32pm UTC](https://forum.kirupa.com/t/taking-contet-from-text-field/636058/1 "2017-02-21T14:32:23Z")

</div>

Hi All

I have written this code on the first (and only) key-frame:  
var red:ColorTransform = new ColorTransform();  
red.color = 0xFF0000;  
shape\_mc.transform.colorTransform = red;  
//----------------  
trace(texter.text)

I have mc on the stage with instance name shape\_mc  
I also have text field name texter.

What I’m trying to do is to take the content of the text field (red) and give this color to the shape\_mc.  
texter.text trance fine, red var as a shape\_mc color transform work fine as well.  
When i white **shape\_mc.transform.colorTransform = texter.text** i get nothing.

what am i doing wrong ?

Thanks

---

<div class="post-metadata">

**Author:** ![TheCanadian](https://avatars.discourse-cdn.com/v4/letter/t/67e7ee/32.png) [@TheCanadian](https://forum.kirupa.com/u/TheCanadian)\
**Post date:** [February 21, 2017, 4:25pm UTC](https://forum.kirupa.com/t/taking-contet-from-text-field/636058/2 "2017-02-21T16:25:13Z")

</div>

You could try something like `.colorTransform = this[tester.text]`

---

<div class="post-metadata">

**Author:** ![erezb1](https://avatars.discourse-cdn.com/v4/letter/e/ebca7d/32.png) [@erezb1](https://forum.kirupa.com/u/erezb1)\
**Post date:** [February 22, 2017, 6:13am UTC](https://forum.kirupa.com/t/taking-contet-from-text-field/636058/3 "2017-02-22T06:13:09Z")

</div>

Tried, didn’t worked.  
Thanks

---

<div class="post-metadata">

**Author:** ![linusj](https://avatars.discourse-cdn.com/v4/letter/l/b2d939/32.png) [@linusj](https://forum.kirupa.com/u/linusj)\
**Post date:** [February 22, 2017, 9:24am UTC](https://forum.kirupa.com/t/taking-contet-from-text-field/636058/4 "2017-02-22T09:24:27Z")

</div>

Shouldn’t it be colorTransform.color?

You’re missing the “.color”

---

<div class="post-metadata">

**Author:** ![tbo](https://avatars.discourse-cdn.com/v4/letter/t/7feea3/32.png) [@tbo](https://forum.kirupa.com/u/tbo)\
**Post date:** [February 22, 2017, 6:52pm UTC](https://forum.kirupa.com/t/taking-contet-from-text-field/636058/5 "2017-02-22T18:52:00Z")

</div>

I haven’t used Flash in the timeline without classes in a while.

I just gave it a shot, and I cannot get the scope correct on the timeline, probably something simple I’m missing. Now I’m curious! I’m unable to reference that existing ColorTransform by string.

However, I can just fine if using Classes, and set the color transform as a class level variable. Then I can just reference by string the way TheCanadian said. this[string];

In a real world scenario, most people would have at least a document class, and you can set the new ColorTransform there, now you can then reference by string all you want

If you dont want to use Classes at all, you may have to do a condition check on the string, then set the colorTransform accordingly.

Here is a smaller example of the problem to solve

```
		var ct: ColorTransform = new ColorTransform();
		var st:String = "ct";
		trace(this[st]); // this does not work, but it does work if that first line is defined at class level.

```

I also tried a few things like ColorTransform(st) and st as ColorTransform … and stuff

---

<div class="post-metadata">

**Author:** ![TheCanadian](https://avatars.discourse-cdn.com/v4/letter/t/67e7ee/32.png) [@TheCanadian](https://forum.kirupa.com/u/TheCanadian)\
**Post date:** [February 22, 2017, 6:59pm UTC](https://forum.kirupa.com/t/taking-contet-from-text-field/636058/6 "2017-02-22T18:59:16Z")

</div>

It should work. Is it inside a function?

---

<div class="post-metadata">

**Author:** ![tbo](https://avatars.discourse-cdn.com/v4/letter/t/7feea3/32.png) [@tbo](https://forum.kirupa.com/u/tbo)\
**Post date:** [February 22, 2017, 7:02pm UTC](https://forum.kirupa.com/t/taking-contet-from-text-field/636058/7 "2017-02-22T19:02:34Z")

</div>

Correct, so the code just as i wrote it was tried both on timeline, and inside a function in a regular project w classes

Then i changed it and declaired the first line (new color transform) in the class, not in the function and it works.

Edit: oh sorry i see where my comment was confusing there

---

<div class="post-metadata">

**Author:** ![linusj](https://avatars.discourse-cdn.com/v4/letter/l/b2d939/32.png) [@linusj](https://forum.kirupa.com/u/linusj)\
**Post date:** [February 23, 2017, 7:55am UTC](https://forum.kirupa.com/t/taking-contet-from-text-field/636058/8 "2017-02-23T07:55:31Z")

</div>

It does work with this[“string”] in Animate cc to reference the colortransform on a layer action. (.color does not work)

---

<div class="post-metadata">

**Author:** ![tbo](https://avatars.discourse-cdn.com/v4/letter/t/7feea3/32.png) [@tbo](https://forum.kirupa.com/u/tbo)\
**Post date:** [February 23, 2017, 6:56pm UTC](https://forum.kirupa.com/t/taking-contet-from-text-field/636058/9 "2017-02-23T18:56:41Z")

</div>

You’re saying if you paste those 3 lines on a frame in animate it traces something? In cs6 i got null or error i forget

---

<div class="post-metadata">

**Author:** ![linusj](https://avatars.discourse-cdn.com/v4/letter/l/b2d939/32.png) [@linusj](https://forum.kirupa.com/u/linusj)\
**Post date:** [February 23, 2017, 7:15pm UTC](https://forum.kirupa.com/t/taking-contet-from-text-field/636058/10 "2017-02-23T19:15:37Z")

</div>

First it didn’t work with stage.getchildbyname(“mc”), so I tried with addChild of mc exported for actionscript and got that working, and then all of a sudden it worked with getChildbyName + the three lines of code.

Still, there is nothing that compares to flash 8. If you ever want mysteries to pond upon 🙂
