Many games have 2p characters, and the action is exactly the same as the 1p character, except that the color of the dress changes. So what do we do to change clothes? You might say that the 2p character is also painted as a set of pictures, which is certainly true, but usually an action game with a picture that can reach hundreds of pieces, Such an approach is really not worthy of approval.
Let's use BitmapData to make the problem simpler.
Here with the characters in the street bully "Red Crazy Ken" as an example, the following SWF, we point to the red Ken, his clothes will become blue color,
Click here to download the source file
Code:
Stage.scalemode = "Noscale";
Import BitmapData Class
Import Flash.display.BitmapData;
Import Flash.geom.Point;
Create a character
var kenbmd:bitmapdata = Bitmapdata.loadbitmap ("Ken", 1);
var kenmc:movieclip = This.createemptymovieclip ("KENMC", 1);
Kenmc.attachbitmap (Kenbmd, 1);
kenmc._x = 100;
Kenmc._y = 10;
Create a palette
var redarray:array = new Array (256);
for (var i = 0; i<255; i++) {
Redarray[i] = "0x00" +i.tostring (16) + "0000";
}
REDARRAY[0XF4] = 0X000000F4;
REDARRAY[0X95] = 0x00000095;
REDARRAY[0XDE] = 0X000000DE;
//
kenmc.onpress = function () {
Kenbmd.palettemap (Kenbmd, Kenbmd.rectangle, New Point (0, 0), redarray, NULL, NULL, NULL);
};