The Flash 8 documentation for perlinNoise() has this intriguing statement:
You can use Perlin noise functions to simulate natural phenomena and landscapes, such as wood grain, clouds, and mountain ranges.
OK. That sounds like fun. But how is this done? It's not immediately obvious, at least not to me. So I googled .
According to these links (here and here), the formula for wood is:
g = perlin(x,y) * 20;
grain = g - int(g);
It looks like we have to do the math on every pixel. After calling perlinNoise, we use getPixel(), mulitply by 20, get the fractional part, then stuff the pixel back in the bitmap with setPixel(). And do that with ever pixel.
That would take forever.
Maybe in AS3 we'll be able to process each pixel individually, but not in AS2. It's too slow. Instead, we need to use the available BitmapData functions to get the same result.
This article describes a way to do that.
Here's an imaginary scan line from a perlin noise bitmap -- just one rgb channel:
Notice that the signal is bounded by 0 and 255 -- the limits of the r, g and b channels in a pixel.
The multiplier of 20 in the above formula is arbitrary. It determines how many tree rings you have in your wood. Let's use 4 instead for diagram purposes:
The g - int(g) part is the same as fraction(g). You can get this by chopping each band and collapsing then together like so:
Believe it or not, if you do this in two dimensions with the amplitude controlling the color, here's what you get:

The key Flash api functions and classes are:
- BitmapData.perlinNoise() (of course)
- ColorMatrixFilter
- BitmapData.threshold()
- BitmapData.draw() with blend modes.
Here's the code:
The above code will render a wood texture to a bitmap.
I made a component to add a wood texture to a movieclip by dragging and dropping the component onto the movieclip. I used it to quickly add the wood texture to the shapes in the Flash movie below.

Problems:
Performance
It seems that the first time the perlin noise is used in a movie, it takes a long time. But subsquent uses are quick. I'm not sure about this. I need to dig in and figure out whether the problem really is the perlinNoise function, or one of the other bitmap api functions.
Perlin Persistance
Perlin noise is supposed to have a parameter called persistance that is used to control how the amplitude decreases with each perlin octave. The Flash version does not have this. Presumably, the Flash perlin function uses a persistance of 0.5, which seems to be the default in the perlin documentation I've read.
If you want more detail in your wood texture, you need to use more than one octave. But wood is supposed to use a low persistance (< 0.5). If you use more than one octave in your wood with too high a persistance, it looks swirly.
I tried to implement persistance other than 0.5 by layering perlin noise bitmaps with different baseX and baseY values (lots of shifting with ColorMatrix and blending with add and subtract). But I couldn't get it too work and was spending too much time on it. Maybe I'll go back to it later.
Conclusion
Of course, if you want a wood texture, you can simply use a jpeg. It's up to you whether this method is worthwhile.
It was a chance for me to get a handle on perlin noise. I probably will use it, however. I want to make a game with Scrabble-like tiles, and I'd like them to not look identical.
Now, how about those clouds and mountain ranges...
