Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Flex Conversion of temperature from kelvin to Celsius:

Related Tutorials


 
 

Share on Google+Share on Google+

Conversion of temperature from kelvin to Celsius:

Advertisement
It is a very famous example and almost everyone of us have done this example once in any language.

Conversion of temperature from kelvin to Celsius:

     

 

It is a very famous example and almost everyone of us have done this example once in any language. So let's see how to do this conversion in flex. We'll come to know how to convert using different GUI of flex. Also in this tutorial we'll see how to put the mxml and action script section in separate
  files, and how to access the action script file from mxml file.

 

 

 

 

 

 



temperature.mxml

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" >
  <mx:Script  source="temperature.as"/>
  <mx:Panel title="Convert Temperature"  paddingBottom="10" paddingTop="10"  paddingLeft="10" paddingRight="10" x="138" y="44">
  <mx:HBox>  
    <mx:Label text="Farenheit" id="f"/>
    <mx:TextInput id="far"/>
    <mx:Button id="button" label="convert" click="convert()"/>
    <mx:TextInput id="cel"/>   
  </mx:HBox>
  </mx:Panel>
</mx:Application>

  temperature.as
public function convert():void
    {
      var f:Number=Number(far.text);
      var c:Number=Number(cel.text);
      c=Math.round((f-32)/1.8*10)/10;
      cel.text=String(c);
    }

   
  

  

 

Advertisements

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: April 3, 2006

Related Tutorials

Discuss: Conversion of temperature from kelvin to Celsius:  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com