Hey, really simple problem… i think. I place a symbol on the stage in the middle and then i have a textbox and when i input a number it moves up and down the axis. However when i press backspace to get rid of the word “rating” and place a number it sends it to the top of the page. Can someone please help me so that when i place a number in then press backspace for another number it returns back to the desired point on the axis. Thank you
package
{
import flash.display.Sprite;
import flash.display.Stage;
import flash.text.*;
import flash.events.*;
public class TextLecture3 extends Sprite
{
private var myTextBox:TextField = new TextField();
private var myOutputBox:TextField = new TextField();
private var myText:String = "Rating";
private var myBall:Ball = new Ball ;
public function TextLecture3()
{
captureText();
}
public function captureText():void
{
myTextBox.type = TextFieldType.INPUT;
myTextBox.restrict = "0-9";
myTextBox.background = true;
myTextBox.border = true;
myTextBox.maxChars = 2;
myTextBox.height = 100;
myTextBox.width = 500;
var xPosition2 = 257;
var yPosition2 = 343;
myBall.y = yPosition2;
myBall.x = xPosition2;
addChild(myTextBox);
addChild(myBall);
myTextBox.text = myText;
trace(myTextBox.text);
myTextBox.addEventListener(Event.CHANGE,positionSymbol);
}
// use for the Event.CHANGE event. Has a different class.
public function positionSymbol(event:Event):void
{
var rating:int = int(myTextBox.text);
var position:int;
// convert rating to position on stage
position =(4 * rating * 10);
trace(position);
if ((position <= 400) || (position >= 0))
{
myBall.y = position;
}
}
}
}