flex-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Saju Thankathurai <sathikeshj...@gmail.com>
Subject Re: Decimal to Hex conversion.
Date Mon, 29 Sep 2014 11:46:51 GMT
Hi,

I tried using int, it didnt help. Below is the demo code,

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
   xmlns:s="library://ns.adobe.com/flex/spark"
   xmlns:mx="library://ns.adobe.com/flex/mx"
initialize="windowedapplication1_initializeHandler(event)" >
 <fx:Script>
<![CDATA[
import mx.events.FlexEvent;
 import spark.events.TextOperationEvent;
 protected function scaledVal_changeHandler(event:TextOperationEvent):void
{
hexVal.text = int(scaledVal.text).toString(16).toUpperCase();
 }
 protected function hexVal_changeHandler(event:TextOperationEvent):void
{
var texts:String = "0x"+hexVal.text;
scaledVal.text = int(texts).toString(10);
}
 protected function
windowedapplication1_initializeHandler(event:FlexEvent):void
{
nativeWindow.maximize();
}
 protected function button1_clickHandler(event:MouseEvent):void
{
scaledVal.text = "";
hexVal.text = "";
 }
 ]]>
</fx:Script>
 <fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
 <s:BorderContainer width="100%" height="100%" borderVisible="true">
 <s:VGroup  verticalCenter="0" horizontalCenter="0">
<s:Label width="100%" color="blue"
 text="Demo to convert hexa to scaled value and vice-versa"/>
 <mx:Form width="100%" height="100%">
<mx:FormHeading label="Enter values into the textbox"/>
 <mx:FormItem label="Enter Scaled value">
<s:TextInput id="scaledVal" width="200"
change="scaledVal_changeHandler(event)"/>
 </mx:FormItem>
 <mx:FormItem label="Enter Hexa value">
<s:TextInput id="hexVal" width="200" change="hexVal_changeHandler(event)"/>
</mx:FormItem>
 </mx:Form>
 <s:Button label="Reset" click="button1_clickHandler(event)"/>
</s:VGroup>
 </s:BorderContainer>
</s:WindowedApplication>



--
Regards


Saju Thankathurai,


*"We **cannot do great things on this Earth, only small things with great
love"*
*-Mother Teresa (1910-1997)*


On Mon, Sep 29, 2014 at 5:06 PM, Evyatar Ben Halevi-Arbib <
evyatarbh@gmail.com> wrote:

> You convert initially using uint, so decimals are omitted.
>
> Regards,
> Evyatar
>
> On Mon, Sep 29, 2014 at 2:22 PM, Saju Thankathurai <
> sathikeshjith@gmail.com>
> wrote:
>
> > Hi,
> >
> > How can we convert a decimal value to Hex value?
> >
> > I need to convert *1345.4567 *value to HEX value. I used the below code
> to
> > convert decimal values to Hex,
> >
> > hexVal.text = uint(scaledVal.text).toString(16).toUpperCase();
> >
> >
> > Below code to convert from Hex to decimal.
> > var texts:String = "0x"+hexVal.text;
> > scaledVal.text = uint(texts).toString(10);
> >
> >
> > The value 1345 is converted to HEX without any issues. But after the
> > decimal part, it is not converting.
> >
> > Could some one give inputs on this conversion.
> >
> >
> > --
> > Regards
> > Saju Thankathurai,
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message