A.I. Jumps

I looked but did not find it so if this question is already asked please redirect me.

Hi im new here so hi…

Question:
Working in Flash CS3 with AS 3, I’m trying to make a character Jump as soon it detects there is no “platform” or there is a higher “platform” in the next few pixels.

The “character” walks in the direction of the mouse, but i want it to jump on its own. I know i can add a Keyboard event but that will destroy the whole purpose of my idea.

So if any one has a clue …its all welcome.

also im using this code for the platform collision( AND IT SUCKS =( )

private function Collide() {
y+= _YV
;
while (_PLATFORM.hitTestPoint(x,y-1,true)) {
y-=1 ;
}
while (_PLATFORM.hitTestPoint(x+width/2,y-1,true)) {
x-=1;
}
while (_PLATFORM.hitTestPoint(x-width/2,y-1,true)) {
x+=1 ;
}

(Im working with OOP)

Thanks in advance,

Sidar