While loops

Hey guys, I’m working on a platformer, and I’m using While loops to smoothly have the character climbing up slopes.
The problem is, getting him to go down the slope isn’t as easy.

I’m using the points defined to check for slopes infront of and behind the character.
The idea was that when the slope behind them was touching and the inair variable was set to true the while loop would force them downwards.

But in practice this only made Flash crash.

So does anybody have any suggestions? Am I perhaps going about this the wrong way?