Hi, here's my cave generator(i'm working in a game that will use this).I'm using the cellular automata 4-5 algorithm and a set of other rules, but i have to work a little more on it, because once in a while i'm getting some big disconnected caves.
Arrows-move and jump
Spacebar-fly
Hold Z to Zoom out and see the entire cave
G-generate a new cave
Random cave capx
Random cave example
UPDATE:you can find above the link to the capx., this is slightly different from the example but you can use your own tiles for the auto-tile function.
Edit:i forgot to paste the comments to this example so if you have any doubts just ask here if you like.