-
dynamic textfields - space evenly?
I have a loop where I create texfields based upon an xml file. SOme of the textfield have one line, some have two. They are autosized.
The problem is that the one line textfields are spacing the same amount as the two lined ones, creating more space in-between those( hence, not spaced evenly);
so it looks like this:
Textfield 1 Line
TextField
2 LInes
TextField
2 LInes
this is the code I am using right now:
Code:
clientButton._y = (clientButton._height + 10) * c;
The 10 is the padding. Anyone know how I could space them evenly?
-FRIG-5
Das Konzept Design
www.daskonzept.com
-
Total Universe Mod
You need to supply more of your code. What does clientButton refer to?
You should be able to record the height of a text field after you've assigned text to it which it looks like you're doing. So you're probably getting the height of the wrong text field. Just post the code that builds and places the text fields.
-
for(c = 0; c<clientsNum; c++){
clientNames.createEmptyMovieClip("button" + c, clientNames.getNextHighestDepth());
clientButton = clientNames["button" + c];
clientButton.createTextField("buttonText", clientButton.getNextHighestDepth(), 0, 0 , 100, 1);
currText = clientsList.firstChild.childNodes[c].attributes.clientName;
clientButton.buttonText.html = true;
clientButton.buttonText.wordWrap = true;
clientButton.buttonText.condenseWhite = true;
clientButton.buttonText.multiline = true;
clientButton.buttonText.htmlText = currText.toUpperCase();
//setButtonText format
clientButton.buttonText.embedFonts = true;
clientButton.buttonText.autoSize = "center";
clientButtonText = new TextFormat();
clientButtonText.size = 10;
clientButtonText.font = "gothammedium";
clientButtonText.wordWrap = true;
clientButtonText.color = 0xFFFFFF;
clientButtonText.leading = 0;
clientButtonText.buttonText.wordWrap = true;
clientButtonText.buttonText.multiline = true;
clientButton.buttonText.setTextFormat(clientButton Text);
clientButton.projectURL = clientsList.firstChild.childNodes[c].childNodes[1].childNodes[0].attributes.websiteURL;
//set Button position
clientButton._x = 20;
spacedOut = (clientButton._height + 10) * c + 30;
clientButton._y = spacedOut;
}
-FRIG-5
Das Konzept Design
www.daskonzept.com
-
Total Universe Mod
you are measuring the button in progress, not the previous one.
set a var prior to the for loop that holds the last buttons height:
var prevHeight:Number = 0;
for (...){
...
}
Then when you get to the point where you need to set the _y, use prevHeight instead of clientButton._height:
spacedOut = (prevHeight + 10)*c+30;
and as the last line of the loop enter:
prevHeight = clientButton._height;
-
nice.. good idea. Iwas trying to do the same thing, just within the same loop like [clientButton + (c-1)]._height instead of making a variable outside of it. Thanks!
-FRIG-5
Das Konzept Design
www.daskonzept.com
-
Total Universe Mod
You could do that too, just remember clientButton only referes to the current button so you'd have to re-evaluate the previous one:
spacedOut = (clientNames["button" + (c-1)] + 10) * c + 30;
The problem with this method is that the first button has no previous to look at.
-
It is still looking at the on line text fields as two liners. So it is putting that extra space in there. Any other suggestions?
-FRIG-5
Das Konzept Design
www.daskonzept.com
-
Total Universe Mod
I would need to see the xml to be sure.
A few things that might help though:
I tend to create text fields with no size to them like clientButton.createTextField("buttonText", clientButton.getNextHighestDepth(), 0, 0 , 0, 0);
Then I set the autosize property so it will just grow to fit the text. This can be a problem when you want multiline so I just pass newline characters (\n) in the text itself. Of course multiline has to be set to true.
As far as settings go, you have mulitline and wordwrap set on both the textfield and the text format. Those are only properties of the text field class, not text format.
To that end, you don't need to re-create the text format each loop. You can just create it once (think CSS) and use setTextFormat() on a line after you've assigned the text.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|