Help in advanture type game

Hi,
Guyes!
I am coming directly to the point,i am working on one adventure type of game,in that the hero will move Left to Right,jump in the air,while jumping if he is near the ledge he will grabe the ledge and hang and while hanging if user click the up key he will climb on the ledge,on the ledge he can walk as soon as he reaches the end of the ledge he will jump down on the ground this is the move of the hero but iam haveing proble on the ledge, hero is not walking properly,some times hanging is haveing problem. so you guyes help me or do you have have any relevant link, please let me know. i am haveing problem with uploading the .swf please see the code and guide me!

Thank’s

Code:

stop();
Stage.showMenu = false;
//Variables & Ojectes//
fscommand(“fullscreen”, true);
fscommand(“allowscale”, false);
fscommand(“showmenu”, false);
score = 0;
health.text = 100;
en_in = false;
en_out = false;
hang = false;
fast_speed = 30;
normal_speed = 15;
to_run_timeout = 4000;
prev_time = getTimer();
current_time = prev_time;
speed_countdown_timer = 0;
document.frameRate = normal_speed;
enemy_timeout = 12000;
vel_y = 0;
accel = 4;
jumping = false;
hero_bounds = new Object();
hero_bounds = hero.getBounds(this);
t_edge = hero_bounds.xMin;
b_edge = hero_bounds.yMin;
curStage = 1;
ground = 5;
hero.climbing = false;
enemy0._x = 1000;
waitCount = 0;
hp = 100;
Points = 0;
lastCheckpoint = [];
hanging1 = false;
hanging2 = false;
changeStage = false;
walk = false;
upFlage = false;
jumpFlage = false;
//----------------------------------------------------------------------------//
this.onLoad = function() {
Direction = “Right”;
};
this.onEnterFrame = function() {
origYpos = hero._y;
speed = normal_speed;
hpBar._xscale = hp;
if (hp<0) {
hp = 0;
if (hp == 0) {
gotoAndStop(“End”);
}
}
//Hero will Stand on the platform//
if (platforms.hitTest(hero._x, hero._y+hero._height/2, true)) {
platform = “on”;
upFlage = false;
hero._y = oriYpos;
}
//check if enemy is hit//
if (hero.hitTest(enemy0)) {
Points = score;
}
// If Hero hits the Ledge//
if (hero.hitTest(ledge_wall1)) {
if (Direction == “Right”) {
hanging1 = true;
}
if (Direction == “Left”) {
hanging1 = false;
}
}
if (hero.hitTest(ledge_wall2)) {
if (Direction == “Left”) {
hanging2 = true;
}
if (Direction == “Right”) {
hanging2 = false;
}
}
for (i=1; i<=ground; i++) {
if (i == 1) {
hero.hits = 0;
}
if (hanging1) {
if (hero.hitTest(eval(“l”+i))) {
hero.hits++;
walk = false;
Ledge = eval(“l”+i);
l_bounds = new Object();
l_bounds = Ledge.getBounds(this);
if (Direction == “Right”) {
if (t_edge<=l_bounds.xMin) {
if (curStage == 3) {
hero._x = l_bounds.xMin-hero._width/2+10;
hero._y = l_bounds.yMin+hero._height/2-12;
}
} else {
}
}
}
}
if (hanging2) {
if (hero.hitTest(eval(“l”+i))) {
hero.hits++;
walk = false;
Ledge = eval(“l”+i);
l_bounds = new Object();
l_bounds = Ledge.getBounds(this);
if (Direction == “Left”) {
if (t_edge>=l_bounds.xMax) {
if (curStage == 3) {
hero._x = l_bounds.xMax-hero._width/2+60;
hero._y = l_bounds.yMin+hero._height/2-20;
} else {
}
}
}
}
}
}
//Moving Left & Right//
if (Key.isDown(Key.LEFT) && !upFlage) {
walk = true;
hero._xscale = -100;
if (walk) {
if (bg._x == 0) {
curStage = 1;
hero._xscale = -100;
Direction = “Left”;
hero.gotoAndStop(curStage);
}
if (bg._x>=-1) {
speed = 0;
curStage = 1;
Direction = “Left”;
hero.gotoAndStop(curStage);
f1._x += speed;
f2._x += speed;
f3._x += speed;
f4._x += speed;
f5._x += speed;
f6._x += speed;
f7._x += speed;
f8._x += speed;
wall._x += speed;
l1._x += speed;
l2._x += speed;
l3._x += speed;
l._x += speed;
mb._x += speed;
ledge_wall1._x += speed;
ledge_wall2._x += speed;
ledge_wall3._x += speed;
ledge_wall4._x += speed;
ledge_wall5._x += speed;
} else {
curStage = 2;
Direction = “Left”;
hero.gotoAndStop(curStage);
prev_time = current_time;
current_time = getTimer();
dt = current_time-prev_time;
speed_countdown_timer = speed_countdown_timer+dt;
if (to_run_timeout>speed_countdown_timer) {
speed = normal_speed;
getDocumentDOM().frameRate = normal_speed;
} else {
speed = fast_speed;
getDocumentDOM().frameRate = fast_speed;
}
f1._x += speed;
f2._x += speed;
f3._x += speed;
f4._x += speed;
f5._x += speed;
f6._x += speed;
f7._x += speed;
f8._x += speed;
wall._x += speed;
l1._x += speed;
l2._x += speed;
l3._x += speed;
l._x += speed;
mb._x += speed;
ledge_wall1._x += speed;
ledge_wall2._x += speed;
ledge_wall3._x += speed;
ledge_wall4._x += speed;
ledge_wall5._x += speed;
}
if (bg._x<=-1) {
bg._x += speed;
platforms._x += speed;
}
}
} else if (Key.isDown(Key.RIGHT) && !upFlage) {
walk = true;
hero._xscale = 100;
if (walk) {
if (bg._x+bg._width<=670) {
speed = 0;
curStage = 1;
bg._x += speed;
platforms._x += speed;
Direction = “Right”;
hero.gotoAndStop(curStage);
f1._x += speed;
f2._x += speed;
f3._x += speed;
f4._x += speed;
f5._x += speed;
f6._x += speed;
f7._x += speed;
f8._x += speed;
wall._x += speed;
l1._x += speed;
l2._x += speed;
l3._x += speed;
l._x += speed;
mb._x += speed;
ledge_wall1._x += speed;
ledge_wall2._x += speed;
ledge_wall3._x += speed;
ledge_wall4._x += speed;
ledge_wall5._x += speed;
} else {
// normal walking on the level //
prev_time = current_time;
current_time = getTimer();
dt = current_time-prev_time;
speed_countdown_timer = speed_countdown_timer+dt;
if (to_run_timeout>speed_countdown_timer) {
speed = normal_speed;
document.frameRate = normal_speed;
} else {
speed = fast_speed;
document.frameRate = fast_speed;
}
Direction = “Right”;
curStage = 2;
hero.gotoAndStop(curStage);
bg._x -= speed;
platforms._x -= speed;
f1._x -= speed;
f2._x -= speed;
f3._x -= speed;
f4._x -= speed;
f5._x -= speed;
f6._x -= speed;
f7._x -= speed;
f8._x -= speed;
wall._x -= speed;
l1._x -= speed;
l2._x -= speed;
l3._x -= speed;
l._x -= speed;
mb._x -= speed;
ledge_wall1._x -= speed;
ledge_wall2._x -= speed;
ledge_wall3._x -= speed;
ledge_wall4._x -= speed;
ledge_wall5._x -= speed;
if ((bg._x+bg._width) == 660) {
curStage = 1;
hero.gotoAndStop(curStage);
}
}
}
} else if (!Key.isDown(Key.RIGHT) && !Key.isDown(Key.LEFT) && !upFlage && curStage == 2) {
walk = false;
if (!walk) {
curStage = 1;
hero.gotoAndStop(curStage);
}
}
//Falling down//
if (gravity == “on” && platform == “off” && !jumping) {
hero._y = hero._y+12;
hero._y = origYpos;
jumping = true;
}
//Jumping//
if (hero.hits<=0) {
//trace(hero.hits);
if (Key.isDown(Key.UP) && !jumping) {
upFlage = true;
if (upFlage) {
curStage = 3;
platform = “no”;
vel_y = 22;
jumping = true;
walk = false;
if (Direction == “Left”) {
if (bg._x<=0) {
speed = 0;
bg._x += speed;
platforms._x += speed;
f1._x += speed;
f2._x += speed;
f3._x += speed;
f4._x += speed;
f5._x += speed;
f6._x += speed;
f7._x += speed;
f8._x += speed;
wall._x += speed;
l1._x += speed;
l2._x += speed;
l3._x += speed;
l._x += speed;
mb._x += speed;
ledge_wall1._x += speed;
ledge_wall2._x += speed;
ledge_wall3._x += speed;
ledge_wall4._x += speed;
ledge_wall5._x += speed;
} else {
bg._x += speed;
platforms._x += speed;
f1._x += speed;
f2._x += speed;
f3._x += speed;
f4._x += speed;
f5._x += speed;
f6._x += speed;
f7._x += speed;
f8._x += speed;
wall._x += speed;
l1._x += speed;
l2._x += speed;
l3._x += speed;
l._x += speed;
mb._x += speed;
ledge_wall1._x += speed;
ledge_wall2._x += speed;
ledge_wall3._x += speed;
ledge_wall4._x += speed;
ledge_wall5._x += speed;
}
}
if (Direction == “Right”) {
bg._x -= 2;
platforms._x -= 2;
f1._x -= 2;
f2._x -= 2;
f3._x -= 2;
f4._x -= 2;
f5._x -= 2;
f6._x -= 2;
f7._x -= 2;
f8._x -= 2;
wall._x -= 2;
l1._x -= 2;
l2._x -= 2;
l3._x -= 2;
l._x -= 2;
mb._x -= 2;
ledge_wall1._x -= 2;
ledge_wall2._x -= 2;
ledge_wall3._x -= 2;
ledge_wall4._x -= 2;
ledge_wall5._x -= 2;
}
}
}
//Make to fall down//
if (jumping == true) {
if (platform == “on”) {
gravity = “on”;
vel_y = 0;
jumping = false;
hero._y = origYpos;
curStage = 1;
hero.gotoAndStop(curStage);
} else {
gravity = “off”;
hero._y = origYpos;
}
//Make to jump up//
vel_y -= accel;
if (vel_y<-12) {
vel_y = -12;
}
hero._y -= vel_y;
hero.gotoAndStop(curStage);
}
}
//---------------------------------------------------------------------//
if (hero.hits>0) {
if (Key.isDown(Key.UP) && upFlage) {
upFlage = false;
if (Direction == “Right”) {
platform = “on”;
curStage = 5;
hero.gotoAndStop(curStage);
hero._x = Ledge._x+hero._width/2-35;
hero._y = Ledge._y+hero._height/2;
L_Ypos = hero._y;
}
if (Direction == “Left”) {
platform = “on”;
curStage = 5;
hero.gotoAndStop(curStage);
hero._x = Ledge._x+hero._width;
hero._y = Ledge._y+hero._height/2;
L_Ypos = hero._y;
}
}
if (Key.isDown(Key.LEFT) && !upFlage) {
platform = “on”;
curStage = 2;
hero.gotoAndStop(curStage);
hero._x = Ledge._x+hero._width/2;
hero._y = L_Ypos-hero._height;
}
if (Key.isDown(Key.RIGHT) && !upFlage) {
speed = 0;
platform = “on”;
curStage = 2;
hero.gotoAndStop(curStage);
hero._y = L_Ypos-hero._height;
}
}
//---------------------------------------------------------------------//
if (hero._x>Ledge._x-hero._width/2 && hero.hits>0) {
if (curStage == 2 || curStage == 1) {
if (Direction == “Left” && hero._x+hero._width/2>=l_bounds.xMin) {
jumping = false;
hero._xscale = -100;
curStage = 6;
hero.gotoAndStop(curStage);
} else if (Direction == “Right” && hero._x+hero._width/2>=l_bounds.xMax) {
trace(l_bounds.xMax);
jumping = false;
hero._xscale = 100;
curStage = 6;
hero.gotoAndStop(curStage);
}
}
}
//---------------------------------------------------------------------//
if (curStage == 6 && platforms.hitTest(hero)) {
hero.hits = 0;
platform = “on”;
jumping = false;
hanging1 = false;
hanging2 = false;
hero._y = (platforms._y-platforms._height)-hero._height-10;
if (platform == “on” && Direction == “Right”) {
if (!jumping) {
curStage = 1;
hero.gotoAndStop(curStage);
hero._x = hero._x+Ledge._width-hero._width;
hero._y = hero._y+hero._height/2-10;
}
}
if (platform == “on” && Direction == “Left”) {
if (!jumping) {
curStage = 1;
hero.gotoAndStop(curStage);
hero._x = hero._x-Ledge._width+hero._width;
hero._y = hero._y+hero._height/2-10;
}
}
}
//---------------------------------------------------------------------//
if (Key.isDown(Key.SPACE) && !walk) {
for (p=1; p<=19; p++) {
if (hero.hitTest(eval(“f”+p))) {
products = eval(“f”+p);
f_bounds = new Object();
f_bounds = products.getBounds(this);
if (Direction == “Left”) {
if ((products._x+products._width/2)<=hero._x+hero._width/2) {
food = eval(“f”+p);
score += 5;
lastCheckpoint[p-1] = food._name;
eval(“f”+p).gotoAndStop(2);
}
} else if (Direction == “Right”) {
if ((products._x+products._width/2)-30>=hero._x+hero._width/2) {
food = eval("f+p);
score += 5;
lastCheckpoint[p-1] = food._name;
eval(“f”+p).gotoAndStop(2);
} else {
}
}
}
}
}
//Enemy move//
if (hero.hitTest(wall)) {
if (Direction == “Right” && enemy_timeout>speed_countdown_timer) {
//en_in = true;
//enemy0._xscale = 100;
} else {
//en_in = false;
}
}
if (en_in) {
enemy0.gotoAndStop(“a”);
enemy0._x -= 10;
if (enemy0._x<=200) {
enemy0.gotoAndStop(“b”);
en_in = false;
}
}
if (waitCount == 60) {
enemy0._xscale = -100;
enemy0.gotoAndStop(“a”);
enemy0._x += 10;
if (enemy0._x>800) {
waitCount = 0;
en_in = false;
enemy0.gotoAndStop(“b”);
enemy0._xscale = 100;
en_in = true;
}
if (hero.hitTest(platforms) && waitCount == 60) {
waitCount = 0;
trace(“waitCount till :”+waitCount);
en_in = true;
enemy0._xscale = 100;
enemy0.gotoAndStop(“a”);
enemy0._x -= 10;
}
}
//------------------------------------------------------------------//
ladder = “off”;
platform = “off”;
gravity = “on”;
};
this.onKeyUp = function() {
trace(“All key’s R Up.”);
speed_countdown_timer = 0;
speed = normal_speed;
if (Key.getCode() == 83) {
jumping = false;
}
};