0
votes

I'm new to flash - sort of. I started Flash a while ago but haven't touched it in two years. That said, I'm used to using AS2.0 and started making a game in 2.0. I'm trying to implement a screen in which the user can choose a characters skin and hair color from a typical color gradient. I have it set so that the skin color does in fact change colors based on what they click.

However, it doesn't remain this way. To get to this screen, there is a main menu with an instance of the character. Within the character each limb is separated into its own movieclip. And each limb is made up of some shading, an outline, and a movieclip of just the skin. On the color change screen, I have each limb separated out and given an instance name. Then, in each limb, I have given the skin portion an instance name. I then change the color of the skin, but upon returning to the main menu, the skin has reverted back to its original color. If I use the button to go back into the character appearance screen, the skin is back to its original color, and not the one the user selected. I guess how can I implement this so that the color choice sticks?

Here's my current code:

import flash.display.BitmapData;
        function changeColor(clip, theColor) {
            var myColor = new Color(clip);
            myColor.setRGB(theColor);
        }
        mc_colorPicker._visible = true;
        mc_colorPicker.colors.onPress = function() {
    srcMC = mc_colorPicker.colors;
    var colorBitmap:BitmapData = new BitmapData(srcMC._width, srcMC._height, true, 
        0x00000000);
    colorBitmap.draw(srcMC);
    colorValue = "0x"+colorBitmap.getPixel(srcMC._xmouse, srcMC._ymouse).toString(16);
    changeColor(RULeg.skin, colorValue);
        }

Thanks!

1

1 Answers

0
votes

I suppose by reading what you've written that you use different instances of MovieClips in the main menu and the character appearance screen.

If its the case, each time you switch between the two screens, all the changes you've made on the character are reverted back : in Flash everytime a MovieClip is instanciated or readed from a new keyframe, its like it was a new MovieClip used. So all changes made inside it (colors, positions of inner movieclips, etc...) are reverted back to its original state (the state it has in the Flash pro library item's first frame).

So to make the changes made durable, you should save the colorValue variable (each time its changed) somewhere accessible from anywhere in your swf (something like a static variable in a class ? or even a global / _root variable, even if its really ugly ^^), and re-apply that color to your character each time you switch between different screen.