There was an article posted today on reddit.com about pixel perfect collision detection in ActionScript 3 which does the collision detection portion of your problem.
The real logic will be what to do when you detect a collision. However, have you ever noticed how most side-scrolling games use a flat walking surface?
One idea (that doesn't require collision detection) is to use a height map like idea. You can use an array (or the pixels in a texture) to determine the height of each section of ground along your surface. As your character moves through the scene you just index the position of the character into your height map.
// How many pixels each index of the heightMap contains.
// You'll probably want to use the same value as the distance
// your character moves when the move left/right key is pressed.
const SECTION_SIZE:int = 10;
// Fill this as a huge array with all the heights and
// the size of this will be (mapHorizontalLengthInPixels / SECTION_SIZE).
// Each element will be the distance from the top of the screen to
// place the character so it looks like it is standing on the ground.
var heightMap:Array = [ /* ... */ ];
// TODO: you might want to Tween to this value so it doesn't look chunky
character.y = heightMap[character.x / SECTION_SIZE];
To use a texture instead of an array, you just put each int
that would have been put into the heightMap
array into a single pixel of a BitmapData object. The advantage to using a texture is you can store a huge amount of information in a small BitmapData Object and use getPixel32() to read it out. You can generate the map once, save it (like as a png) and then embed it into the SWF.
If you want to get fancy, and you probably will if you want platforms, bridges, moving objects and more ... then use a 2d physics engine. There are a few open-source projects already including APE, Box2dAS3, Fisix, and FOAM among others. The learning curve will be higher and the coding more difficult but it may pay off for you in the end. Heck, it is an experience itself to write one from scratch if your keen!