views:

32

answers:

1

I am trying to take a movieclip of a character and change the colour of their clothes. The character is comprised of vectors.

So far I have semi-sucessfully used this method:

  1. stop the movieclip
  2. take the bitmap data from the current frame
  3. use threshold to replace the colour
  4. store the resulting bitmap data in an array
  5. add an onenterframe function - clear the current frame and add the bitmap data from the processed data in the array

So - this works pretty well. Each frame is only processed once at the beginning and then the write to the movieclip is very quick.

However! As the replacement is being performed on a bitmap there is an amount of aliasing that takes place to remove jaggies/pixelation. This produces colours that are not matched using threshold. So the main colour is replaced correctly but it is surrounded by a halo of mixed colours :(

I am sure there should be a better way to do this. Any ideas or answers would be greatly apreciated - Thanks.

A: 

Would playing with Grant Skinner's easier to use ColorMatrix class ) get the job done ?

George Profenza
Thanks George - unfortunately the actual colour transformation itself isn't the problem so much as either being able to select individual vectors by colour or, if dealing with the rendered bitmap data, setting a tolerance so surrounding aliased pixels are selected and transformed accordingly too.Thanks for your time though.
Oli
There is a a way you could do that with vectors, but it's bit more difficult. It involves decompiling the swf that contains the shapes at runtime(using as3swf), looping through shapes and replacing colors. Here is an answer that just covers decompiling and counting colors: http://stackoverflow.com/questions/2031343/flex-how-to-count-colors-in-swf-vector-file
George Profenza