Color picker in game, used for multiple objects?
Hi! I've been struggling all morning on this since there appears to be no easy answer. I'm building a character creator, and I want the user to be able to chose colors of skin tone and clothes color, etc. A search reveals the "easiest" way is to add a color picker. But as I want multiple objects to be changeable, I'm running into trouble.... Plus, I'm not a fan of the drag and drop method, way to messy... I already have a substitute method arranged that allows all customizations to be button selected.
Here is where my problem occurs... The code I found to create the color picker assumes all active movie clips are on the same frame, and possibly layer to the picker. Here is the tutorial I've found: Flash Actionscript 3 Tutorial by pichu90 on DeviantArt
I've adapted their code, and every time, at every arrangement I get errors... My current for is rather simple, from one & two unrelated loader code, frame 3 Button code for selecting body type as follows:
var myGenderArray = [male, female, none];
for each (var Gender in myGenderArray) {
Gender.addEventListener(MouseEvent.CLICK, onGenderClick);
}
function onGenderClick (event:MouseEvent):void {
MovieClip(parent).body1.gotoAndStop(event.target.name);
}
The listed values, male, female, none, all comply to a frame table on a movie clip where in the color picker code resides, as well as on buttons that can be clicked to activate those frames.
On each frame an additional movie clip that is to be the color changing tone sits in line with my line art. They each have an instance name to be called upon.
Here is the code that is my main problem:
import fl.controls.ColorPicker;
import fl.events.ColorPickerEvent;
import flash.geom.ColorTransform;
var SkinFemalecolorInfo:ColorTransform = MovieClip().SkinFemale.transform.colorTransform;
MovieClip().CPer1.addEventListener(ColorPickerEvent.CHANGE, colorChange2);
function colorChange2(event:ColorPickerEvent):void {
MovieClip().SkinFemale.transform.colorTransform = MovieClip().CPer1.selectedColor;
}
This is the code for the female frame, on the male and none frames the "SkinFemale" is SkinMale or SkinNone. As well, CPer1 is the representative of the unique color picker, and there is also CPer2 and CPer3. Finally, functions have unique names, I believe, so the other two are called colorChange1 and colorChange3. You'll notice both SkinFemale & CPer1 have a MovieClip(). infant of them. This is because otherwise they will be undefined by flash as this code is within a movie clip its self. (or some logic to that effect, in my experience this is true please do offer alternate answer I've been looking)
I've messed with this code so much I don't know if it can even be saved.... but I'd greatly appreciate anyone who could solve my mystery.