views:

48

answers:

1

I have a Width and Height parametr. I have been given an array of colors in such format: [r, g, b, a, r, g, b, a, r, g, b, a... etc] Data can be acsessed by something like this

for(var y = 0; y < height; y++)
{
   for(var x = 0; x < width; x++)
   {
      r = data[y*width + x + 0]
      g = data[y*width + x + 1]
      b = data[y*width + x + 2]
      a = data[y*width + x + 3]
   }
}  

I want to paint that data on some sprite. How to do such thing?

BTW: I use Flash Builder for mxml+actionscript coding. So if it is easy for you you can give example using MXML (not todraw on some sprite but on some MXML component).

+1  A: 

I'm not sure why you would want to do that in MXML, you're probably better off doing this in coding this in AS3 by drawing on a sprite and then add the sprite as a child to a MXML component.

Try using the BitmapData class, it has a setPixel() method that lets you set RGBA values.

ilikeorangutans
I do not care where to do it AS orMXML - not lot of difference- I want to know how!)
Blender
why the downvote? He answered your question perfectly. SetPixel. if you merge the data together into a ByteArray (using bitwise shifts to merge channels together) you can use the BitmapData.setPixels method. Whether you use MXML or AS doesn't matter.
jonathanasdf