Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

how do i justify text with math

Posted on 2008-10-21
2
Medium Priority
?
643 Views
Last Modified: 2012-05-05
I need to write an algorithm that will full jusity a number of text links along a line in action script.  i can read any programming language so information in any language is appreciated.

The idea is this:

if therer are 5 links of various sizes that are situated on a menu that can be 600 pixels wide, i need  to center then and adjust the spaces between each item such that the fill the available horizontal area.  Dont worry about what happens if they over fill the available space.
0
Comment
Question by:Edanisko
2 Comments
 
LVL 9

Accepted Solution

by:
jhshukla earned 2000 total points
ID: 22772524
>> text links along a line in action script
AFAIK, action script has something to do with flash. So why in C??

that aside, here are the things you will need:
(1) some sort of graphics object or class that can give you dimensions of a given text string.
(2) the fonts (+ size, bold/italics decoration)
(3) the actual text you want to display

use the above three to get the sizes of links and add them to get total size : call it total_size
(600 - total_size)/(num_items - 1) = spacing you need between two links

We will need more info on what environment you are developing in to write pseudo code.
0
 
LVL 2

Author Comment

by:Edanisko
ID: 22772620
Yes.

there here it is in AS3
for(var i:int=0; i<=_NavItems.length-1;i++){
	if (i==0){
		_NavItems[i].x = 0;
	} else {
		_NavItems[i].x =amountOfSpaceBetweenLinks + _NavItems[i-1].x + _NavItems[i-1].width;
	}
	_NavItems[i].visible=true;
	
}

Open in new window

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question