Fx{r} is trying to start the Fx{r} Community! Please join our group on Adobe Groups following this link: http://groups.adobe.com/groups/ab29539ab9.
Fx{r} is now on Twitter too. Follow us @ twitter.com/fx_r!
« Flex Camp Triangle - How Was It?
» Flexer Goes to MAX Milano

ActionScript, Bugs, Flex 2, Flex Builder 3, Web Service

Number.toString bug

Virgil Cristea | 20.11.08 | 4 Comments

Last week I had to write a small piece of code to send to a webservice a number from a text input. All was fine for the normal test values (0,1,100). The problem appeared when I tried to send the number -9223372036854775808. Instead of receiving this number I got -9223372036854776000.  So I started to do some debugging I saw that the problem was in the soap functions from the Flex SDK when they did a number.toString().

I did a small test project to verify that the issue is with the toString() function. Here is the code:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="160" height="70">
	<mx:Script>
		<![CDATA[
			[Bindable]
			public var stringValue:String = "-9223372036854775808";
			[Bindable]
			public var numberValue:Number = Number(stringValue);			
 
			private function testToStringIssue():void
			{
				lbl.text = numberValue.toString();
			}
		]]>
	</mx:Script>
	<mx:Label x="10" y="10" text="{stringValue}" id="lbl"/>
	<mx:Button x="10" y="36" label="Button" click="testToStringIssue();"/>	
</mx:Application>

As you see we first display the stringValue and that is ok. Then we do a number toString() and display that result.

Share and Enjoy:
  • TwitThis
  • Technorati
  • StumbleUpon
  • del.icio.us
  • NewsVine
  • Reddit
  • Digg
  • Furl
  • co.mments
  • blogmarks
  • Slashdot
  • description
  • Taggly
  • YahooMyWeb
  • connotea
  • Webride




Tags: , , , ,

This post was written by Virgil Cristea

Views: 1519

related

4 Comments

have your say

Add your comment below, or trackback from your own site. Subscribe to these comments.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

:

:


« Flex Camp Triangle - How Was It?
» Flexer Goes to MAX Milano