Solved

how do i justify text with math

Posted on 2008-10-21
2
625 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 500 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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
web services creation SOAP vs REST 5 42
use lov values 2 50
Java exception bubble up 2 18
Java Restore security prompts not working 10 13
Article by: Nadia
Suppose you use Uber application as a rider and you request a ride to go from one place to another. Your driver just arrived at the parking lot of your place. The only thing you know about the ride is the license plate number. How do you find your U…
Prime numbers are natural numbers greater than 1 that have only two divisors (the number itself and 1). By “divisible” we mean dividend % divisor = 0 (% indicates MODULAR. It gives the reminder of a division operation). We’ll follow multiple approac…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

803 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