Photoshop Tutorials, Flash Tutorials, 3Ds Studio Max Tutorials, Web Design Tutorials


Software Tutorials

Featured Free Templates
View All Templates!
Preview  |  Download
Name: metamorph_flame
Downloads:
Preview  |  Download
Name: metamorph_skyandclouds
Downloads:
View All Templates!
Recommended Hosting:
Host Unlimited Domains on 1 Account
1500GB storage and 15000GB bandwidth for $6.95/mo!
Recommended Hosting:
Host Unlimited Domains on 1 Account
1500GB storage and 15000GB bandwidth for $6.95/mo!
:: Free Website Templates
Preview  |  Download Preview  |  Download Preview  |  Download
Name: metamorph_sunset Name: metamorph_flower Name: metamorph_waterfall
Downloads: Downloads: Downloads:

Do You Like Our Website? Share With Others!
GoogleGoogle slashdotYahooMyWebDiggTechnoratiDelicious
Page: 12345678910111213141516171819202122232425

Welcome To WebDesignTutorials.net Flash Tutorials Area - Displaying Fractions Correctly

Im trying to create a function that will displays fractions in a textfield in the correct format, because 1/4 or 1/2 isnt being accepted by e-learning people as the correct way to display a fraction. So to do this dynamically, i just thought about creating a 3 line dynamic textfield on the fly, placing the numerator of the fraction on the first line, a dash on the second line and the denominator on the third line and then changing the lineSpacing of the textfield to squeeze it all together vertically, but of course, this is the only property of the TextFormat object that is missing and thus cannot be set dynamically, nor can you pass a negative integer as a value for the TextFormat.leading property unless you specify it using the leading attribute of the textformat html node and pass it to the htmlText property of a textfield(Thanks to Peter Hall)....

So ive created a movieclip method that will display a fraction correctly for you. This function creates one container movieclip, which inside contains two textfields and one movieclip, the first textfield contains the numerator, the second textfield contains the denominator and the movieclip contains a line between the numerator and the denominator drawn using the drawing api.

MovieClip.prototype.createFractionField=function(name,depth,x,y,numerator,denominator,lineSpacing)
{
var cnt=this.createEmptyMovieClip(name,depth,{_x:x,_y:y})
cnt.createTextField("numerator",1,0,0,0,0)
var numeratorF=cnt.numerator
var dash=cnt.createEmptyMovieClip("dash",2)
cnt.createTextField("denominator",3,0,0,0,0)
var denominatorF=cnt.denominator
numeratorF.autoSize=denominatorF.autoSize=true
numeratorF.text=numerator
denominatorF.text=denominator
var nw=numeratorF._width
var dw=denominatorF._width
var gw=(nw>=dw) ? nw : dw
var hw=gw/2
numeratorF._x=hw-(nw/2)
denominatorF._x=hw-(dw/2)
dash.lineStyle(0,0x000000)
dash.lineTo(gw,0)
dash._y=numeratorF._height+lineSpacing
denominatorF._y=dash._y+dash._height+lineSpacing
}

And you use it like this:

//display 1/10 correctly as a fraction for me
this.createFractionField("myFraction",1,0,0,1,10,2)

Displaying Fractions Correctly Tutorial: Final Result

Author: Guy Watson

Advertisements
Graphic Software, Flash Templates, Free Stock Photos, Web Templates, Web Design, Corporate Web Design, Royalty Free stock Photo, Affordable Website Design, Submit site, Add Url, Stock Photos, Survey Software, Anti Virus Software, E mail software, Computer Software

Premium Partners
  Free Website Templates - Flash templates, Affordable Website Design, Website Templates, Website Redesign, Custom Website Design, Web Design Tutorials, Flash Tutorials, Promotion Tutorials - that is what we do. Metamorphosis Design Studio offers quality, free and low cost web site templates for your business and personal life, we also offer affordable web design and site re-design.
  Vertex Website Tempales - It saves tones of time and money to use pre-made web designs to build your web site. You need a web site but you don't want to pay thousands dollars to professional web design companies? Our web templates is just for you! They are designed to be easilly edited by your favorite html editor, like MS FrontPage
  Photoshop Tutorials - Learn how to build stunning web pages using Adobe Photoshop, Macromedia Flash MX and 3D Studio Max software. The step-by-step approach makes it so easy, that even beginners can produce great web pages. Get started with these tutorials covering everything from page layout to content tips.
Free website templates and paid web templates are great tools to make your websites look perfect! You will save time and money with our flash templates and free website templates Our visitors are satisfied with the quality of our free and paid website templates! Please visit our free website templates and paid website templates sections. We offer free web templates, free web layouts, free web page templates and other stuff for free download. All templates come with the html and external css file so you may easily edit HTML with your favorite HTML editor. Feel free to download our free web templates for your personal websites.

Terms of use depend upon the website template vendor.
Home  |  Submit Tutorial  |  Top Sites  |  Free Templates  |  Website Templates  |  Privacy Policy  |  Contact Us
All Right Reserved by WebDesignTutorials.net