Hi thanks, so this is for a vertical menu or positioning vertical
textFields, 

i will try and adjust this for horizontal purposes and measure the width as
opposed to the height then?

-----Original Message-----
From: flashcoders-boun...@chattyfig.figleaf.com
[mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Sidney de
Koning
Sent: 25 August 2009 14:22
To: Flash Coders List
Subject: Re: [Flashcoders] spacing horizontal dynamic xml menu textfields

Hi Thomas,

Try to do something like this and adjust it to your own needs;

// When you are in a for loop, create new items and and try to measure  
the height of an item.
// And position items vertically.You need to remember the previous  
item, the fastest way to do this is to have a runningY var declared  
outside the for loop with an initial value of zero.
//See comments in code for further explanation.

var runningY:Number = 0;
var OFFSET_X:Number = 20;
                        
for (var index:int = 0; index < 4 ; index++) {

        var _textheader:TextField = new TextField( );
        _textheader.text = "Text";
        _textheader.autoSize = TextFieldAutoSize.LEFT;
        _textheader.x = _background.x - _background.width / 2 + OFFSET_X;
        // First iteration  runningY = 0;
        // Second iteration runningY = 0 + textHeader.height +2;  
textHeader.height = 20
        // Third iteration  runningY = 22 + textHeader.height +2;  
textHeader.height = 40 -- mutiple lines of text
        // Fourth iteration runningY = 64 + textHeader.height +2;  
textHeader.height = 20
        // Fifth iteration  runningY = 86
        _textheader.y = runningY;
        runningY += _textheader.height + 2; // textheader = 20
}



On Aug 25, 2009, at 3:06 PM, thomas horner wrote:

>
>
> Hi all am struggling to position, my textFields generated within my  
> loop
> from my external xml,
>
>
>
> i want to evenly space them and as they are dynamic they are all of
> different sizes.
>
>
>
> i have run a trace on the loop as follows;
>
>
>
> trace(navbut.label.width);
>
>
>
> which gives me the widths of each field how do it add the total of the
> widths from the loop? to then space them.
>
> _______________________________________________
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to