I am fairly new to actionscript, and by fairly I mean incredibly. Before someone tells me that I should have searched the forum before posting an easy question like this one probably is that has already been posted and responded to a hundred times, I did try to search but I kept getting an error page saying something is wrong with the site. So anyways, what I am trying to do is have a text box display the number 100. Then there are two buttons. When one is hit, the number bisects between itself and last number lower than it displayed, when the other is hit it bisects between itself and the last number larger than it displayed. For instance, hitting the first button will change the value to 50 then when hit again to 25. If you then hit the second button it goes to 37.5 and then hit that button again it goes to 43.75. I have the following code:
var ce:Number=100;
ce0_txt.text=String(ce);
ce0left_btn.addEventListener(MouseEvent.CLICK, bisectdown);
function bisectdown(event:MouseEvent):void { ce = ce * .5
};
ce0right_btn.addEventListener(MouseEvent.CLICK, bisectup);
function bisectup(event:MouseEvent):void {ce = (2 * ce - ce) * .5
};
The first problem with it is that the text box never changes from 100 when you hit the buttons. The second problem is that the equations in the functions dont do exactly what I want them to do. They work bisecting down only if you never the up button (otherwise it doesnt bisect it with the number immediately before it) and the same going up. Telling me where I messed up with the first question is most important, and any brainstorming as to how to construct an equation for the second question would also be very appreciated. If you need more info i can supply it, if this post is far too long let me know and ill be more brief next time.