rgarimella
asked on
Spacing Dynamic TextFields Y axis in AS3
Hi Folks,
I was trying to position the text dynamically, especially the y axis.
I want that there should be always 40 pixels difference between all the textfields irrespective of their height.
How do I get the calculation/logic so that y and 40 pixel difference is calculated from the last line of the text of the previous text field.
Thanks
RG
The code below shows 40 pixel difference but does not calulcate the height of the TextField.
I was trying to position the text dynamically, especially the y axis.
I want that there should be always 40 pixels difference between all the textfields irrespective of their height.
How do I get the calculation/logic so that y and 40 pixel difference is calculated from the last line of the text of the previous text field.
Thanks
RG
The code below shows 40 pixel difference but does not calulcate the height of the TextField.
var tTimer:Timer = new Timer(50, 1); // adding a new timer that will trigger ONCE
tTimer.addEventListener("timer", positionText); // Adding a listener, that will trigger after the estimated time (50ms)
tTimer.start(); // initialising the timer
function positionText(event:TimerEvent):void {
for(var i:int = 0; i < _totalDistractors ; i++) {
//*******
var taradioButtoni:TextField = new TextField();
taradioButtoni.multiline = true;
taradioButtoni.wordWrap= true ;
taradioButtoni.text = answerChoices[i];
taradioButtoni.width = 380;
taradioButtoni.x = 60;
taradioButtoni.y = answerY + i*(taradioButtoni.textHeight + 40);
trace("y " + taradioButtoni.y);
addChild(taradioButtoni);
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Perfect
Thanks so much
RG
Thanks so much
RG
TextPositioning.fla.zip