Revision: 13974
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at May 14, 2009 10:11 by sidneydekoning
Initial Code
// 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; 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 + TOP_LEVEL_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 }
Initial URL
Initial Description
Initial Title
Spacing items vertically (y axis)
Initial Tags
Initial Language
ActionScript 3