# Variable Help Please AS2.0

**URL:** <https://forum.kirupa.com/t/variable-help-please-as2-0/237107>\
**Category:** flash\
**Created:** [August 27, 2007, 12:27pm UTC](https://forum.kirupa.com/t/variable-help-please-as2-0/237107 "2007-08-27T12:27:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![matrix8369\_yaho](https://avatars.discourse-cdn.com/v4/letter/m/e9a140/32.png) [@matrix8369\_yaho](https://forum.kirupa.com/u/matrix8369_yaho)\
**Post date:** [August 27, 2007, 12:27pm UTC](https://forum.kirupa.com/t/variable-help-please-as2-0/237107/1 "2007-08-27T12:27:59Z")

</div>

Hello I am making a golfing game and am trying to get the ball to change its angle when it hits the lvl wall. The lvl is a diffrent shape on each hole so I have spent a few days trying to think of how to make this happen and finally came up with somthing but the varibale isnt working so can some one please help. I am using ActionScript 2.0 and this is what I have as an idea. When the club is released to hit the ball the var num is set to 1 since this is the first x and y axis in this set of bounces. I then set newx\_+\_root.num = \_root.ball._x and newy_+\_root.num = \_root.ball._y, then I increment num++ so that when the ball does a hit test for when it hits the wall newx_+\_root.num = \_root.ball._x and newy_+\_root.num = \_root.ball.\_y are set again but this time num is = 2 since it is the second axis needed to preform the angel change. Also on the ball to wall hit test i want to campare the newx\_x and newy\_y to the to the newx\_x-1 and newy\_y-1 to see how the angle needs to be changed.

This is the code i am working with atm.

when the club is released  
_root.num=1;  
var newx_+\_root.num = \_root.ball._x;  
var newy_+\_root.num = \_root.ball.\_y;  
\_root.num++;

when the ball hits the lvl wall  
var newx\_+\_root.num = \_root.ball._x;  
var newy_+\_root.num = \_root.ball._y;  
if(newx_+_root.num \> newx_+(\_root.num-1)){  
ball._x = xspeed;  
}else if(newx_+_root.num \< newx_+(\_root.num-1)){  
ball._x = xspeed\*-1;  
}else if(newy_+_root.num \> newy_+(\_root.num-1)){  
ball._y = yspeed;  
}else if(newy_+_root.num \< newy_+(\_root.num-1)){  
ball.\_y = yspeed\*-1;  
}  
\_root.num++;
