Solved

how do i justify text with math

Posted on 2008-10-21
2
629 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

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

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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

729 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