Log in

View Full Version : implementing ColorTransform class



evan
06-12-2008, 10:21 PM
I have been looking at a example here (http://www.alex-uhlmann.de/flash/animationpackage/ap1/de/alex_uhlmann/animationpackage/animation/ColorTransform_doc.html)

about using color transform class.


I had two ideas in how I could "change the color of this movieclip instance.

1) create an array and target frames in the movieclip that would change it's color.

2) I commented that out(for now) and tried to use the colortransform class
any suggestions?

Medyman
06-13-2008, 12:42 PM
This would really depend on your end goal. Regardless of the method, I would still use colorTransform. Changing frames etc, can get really messy and it's going to get really complicated for you if you do it that way. Changing the color dynamically and on-the-fly is far more error proof.

With that said, you could use the colorPicker component if you want to give users a more complete color pallete. Or, if you just want them to pick from a set color pallete (a la MS Paint), you can assign the hex value as a property to that object and then call it that way.

evan
06-13-2008, 03:02 PM
While it's the best way to get the job done....:rolleyes:
(I opted for the colorpicker option-myself being as that you can limit the color swatches -and you can enlarge the colorpicker to make it apear easier to use.)-but ignoring that:

-I will still need to design an interface that adds properties to the mc being dragged and redrawn -such as color and size asigned to buttons, that would change the color to a "brush" texture or shape, which is more complicated, concidering the number of variants -tools/sizes/colors gets to be at least 80 possibilities -I will have a text box and arrows to control size which makes it easier.


I also thought that since, there will be a number of mc's with different shapes, I should set up a list of properties and store them in an array, and on slecting a tool, then it's color -the array will assign the property to that object.



-this would avoid doing about 40 or so functions to assign colors.

I though I could assign some properties I can use "globally" such as this for the API pencil

lineSyle(1, 0x000000);


And this to change colors of the movieclip "brush" shapes.


var circle: MovieClip = new Circle();
addChild(circle);
var ct:ColorTransform = new ColorTransform();

//invert
ct.redOffset = 255;
ct.greenOffset = 255;
ct.blueOffset = 255;
ct.redMultiplier = -1;
ct.greenMultiplier = -1;
ct.blueMultiplier = -1;
circle.transform.colorTransform = ct;

Medyman
06-14-2008, 08:04 PM
You should really start doing things a lot more dynamically. For example, create functions that take certain parameters and can handle varied situations for you. It seems like your hardcoding a lot here.

The general rule of this is that if you're creating similar functions with varied colors/sizes/positions, then you can probably combine them and use variables in some way to minimize your code.

evan
06-16-2008, 02:16 PM
I had a feeling there was a new "zen". Yes, I am learning at this phase what I can and cannot do with flash and how to deal with it -on a very basic level.

I understand what you are saying, -thus far I have been using sample code, spliced and customized it and made some discoveries.

Any recommended reading on working more dynamically?-tutorials -etc.

In the mean time I could set a number of booleans RED, BLUE GREEN YELLOW etc
and with each function I could set the MC to change color or default back to black.
Then globally make a way to resize the MC.