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.
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
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