Slope detection in AS3 platformer

Hey,

I have an art based platformer with a movie clip that is basically a triangle shaped object that serves as the slope.

My problem is in the collision detection with the slope. Here’s the code that i currently have -

<code>
if (_rec.hitTestObject (_slope.x, _slope.y, true))
{
_rec.y = _slope.y - Math.abs (_rec.x - _slope.x);
}
</code>

This basically places the rectangle shape that serves as the main player (_rec) along the slope and increments its y position based on it’s current x position. The reg point of the slope is on the bottom left.

The problem is that this code comes into effect even if _rec is jumping over the triangle because of the square shaped hitbox of the slope. Also, for the same reason, I cannot jump while on the slope itself.

I know of a way to rotate the character based on the incline in the ground but I don’t really like that idea. The character should stay vertical at all times. I really don’t want to do a tile based version as I have a lot of art already designed, it’s only the ground objects that are basic shapes.

Any help would be appreciated.