taking contet from text field

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

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

Tried, didn’t worked.
Thanks

Shouldn’t it be colorTransform.color?

You’re missing the “.color”

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

It should work. Is it inside a function?

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

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

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

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 :slight_smile: