Re: [Flashcoders] Problems when converting to Number
Anthony Pace skriver: trace(Number('1992.2')); //why does it output 1992.3 //I am assuming I am missing something pretty obvious First it is parsed to binary floating point, losing accuracy and then it is output as decimal form again, losing accuracy again. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] My first code.
@Q 1: You don't use the ToggleButton class to create the instances in that way, the class handles the properties and methods. And in your main (document) class or on the timeline in AS you set: private var toggleButton1:ToggleButton = new ToggleButton(); private var toggleButton2:ToggleButton = new ToggleButton(); HTH, Cor van Dooren -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of John McCormack Sent: zondag 19 december 2010 12:51 To: Flash Coders List Subject: Re: [Flashcoders] My first code. On 15/12/2010 23:53, spyder spyders wrote: >I am trying to write a ToggleButton Class.I can get it to work as a document class and as as3 on timeline. But how to I use it as a symbol class? Q. "I am guessing that the 'this' is pointing to the symbol or _mc I attach the class to?" Not attach, but define. The class defines the object and 'this' refers to the one (instance) being accessed: Let's say you use the ToggleButton class to create two instances: public var toggleButton1:MovieClip; // ** public var toggleButton2:MovieClip; and somewhere you call someMethod() on toggleButton1... toggleButton1.someMethod(); // 1 or toggleButton2.someMethod(); // 2 Then once inside someMethod(), the reserved variable 'this' would refer to operations on toggleButton1 on line 1 and toggleButton2 on line 2. Q. "But how to I use it as a symbol class?" Let's say it's not the document class. Save the file ToggleButton.as. In your new code create a new symbol called ToggleButton for the library and in its properties you name the file ToggleButton.as Any code after that can just declare it as in ** and use it as in 1 and 2. Those books will be a big help. John ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders - No virus found in this message. Checked by AVG - www.avg.com Version: 10.0.1170 / Virus Database: 426/3320 - Release Date: 12/16/10 ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] My first code.
Right-Click object in Library, Click Linkage Select Export for Actionscript Set the ToggleButton as Base class file Groeten, Cor van Dooren www.codobyte.com -- "There are only 10 types of people in the world: Those who understand binary and those who don't." -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of John McCormack Sent: zondag 19 december 2010 12:51 To: Flash Coders List Subject: Re: [Flashcoders] My first code. On 15/12/2010 23:53, spyder spyders wrote: >I am trying to write a ToggleButton Class.I can get it to work as a document class and as as3 on timeline. But how to I use it as a symbol class? Q. "I am guessing that the 'this' is pointing to the symbol or _mc I attach the class to?" Not attach, but define. The class defines the object and 'this' refers to the one (instance) being accessed: Let's say you use the ToggleButton class to create two instances: public var toggleButton1:MovieClip; // ** public var toggleButton2:MovieClip; and somewhere you call someMethod() on toggleButton1... toggleButton1.someMethod(); // 1 or toggleButton2.someMethod(); // 2 Then once inside someMethod(), the reserved variable 'this' would refer to operations on toggleButton1 on line 1 and toggleButton2 on line 2. Q. "But how to I use it as a symbol class?" Let's say it's not the document class. Save the file ToggleButton.as. In your new code create a new symbol called ToggleButton for the library and in its properties you name the file ToggleButton.as Any code after that can just declare it as in ** and use it as in 1 and 2. Those books will be a big help. John ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders - No virus found in this message. Checked by AVG - www.avg.com Version: 10.0.1170 / Virus Database: 426/3320 - Release Date: 12/16/10 ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] My first code.
On 15/12/2010 23:53, spyder spyders wrote: I am trying to write a ToggleButton Class.I can get it to work as a document class and as as3 on timeline. But how to I use it as a symbol class? Q. "I am guessing that the 'this' is pointing to the symbol or _mc I attach the class to?" Not attach, but define. The class defines the object and 'this' refers to the one (instance) being accessed: Let's say you use the ToggleButton class to create two instances: public var toggleButton1:MovieClip; // ** public var toggleButton2:MovieClip; and somewhere you call someMethod() on toggleButton1... toggleButton1.someMethod(); // 1 or toggleButton2.someMethod(); // 2 Then once inside someMethod(), the reserved variable 'this' would refer to operations on toggleButton1 on line 1 and toggleButton2 on line 2. Q. "But how to I use it as a symbol class?" Let's say it's not the document class. Save the file ToggleButton.as. In your new code create a new symbol called ToggleButton for the library and in its properties you name the file ToggleButton.as Any code after that can just declare it as in ** and use it as in 1 and 2. Those books will be a big help. John ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] problem with adding two digits
to prevent anyone answering on this thread: after toying with it again, and reading the docs + wikipedia I figured out that I can only trust a result of 15 digits or less, unless I have the string be returned instead of the number. n 12/18/2010 8:34 PM, Anthony Pace wrote: function floatSumV3(roundDown:Boolean = true, ... nums):Number{ var nl:uint = nums.length; var ls:Number=0; //left side var pp:int; //period position var rs:Number = 1; //right side var rsl:int; //right side length var ml:int = 0; //max length right side var powerCounter:int = 1; var powerResult:int; var s:String; for (var i:int = 0; i< nl; ++i) { s = nums[i].toString(); pp = s.indexOf('.'); if(pp!=-1){ rsl = s.length - pp-1; if(rsl>ml){ p ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Problems when converting to Number
Thanks for the response. Right as you were posting, I was posting my own message of how I read up on the spec, and saw the same thing. From what I have read, as you can't actually have the int portion be 9 999 999 999 999 999, because its limit is 9,007,199,254,740,992 , you can really only trust the use of Number up to 15 digits of accuracy. Let me know if I am wrong. On 12/19/2010 4:33 AM, Gerry Beauregard wrote: You're getting to the limits of the precision of a Number. In ActionScript 3, the Number type is stored in binary, in 64-bit double-precision IEEE floating point format: http://en.wikipedia.org/wiki/Binary64 It uses 52 bits for the mantissa (fractional part) which gives it an effective precision of 53 bits, equal to about 16 decimal digits of precision. The error you're getting is in the 17th digit - no surprise at all. -Gerry On 2010-12-19 , at 09:55 , Anthony Pace wrote: trace(Number('1992.2')); //why does it output 1992.3 //I am assuming I am missing something pretty obvious ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Problems when converting to Number
Oh well, after reading a couple of articles, I think I have confirmed my suspicion; for, as I thought, it just comes down to there being too many digits, and the floating point implementation doing some hidden weirdness. It really sucks that you can really only expect about 15 digits of true accuracy from the Number Data type. If I am wrong let me know. On 12/18/2010 8:55 PM, Anthony Pace wrote: trace(Number('1992.2')); //why does it output 1992.3 //I am assuming I am missing something pretty obvious ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Problems when converting to Number
You're getting to the limits of the precision of a Number. In ActionScript 3, the Number type is stored in binary, in 64-bit double-precision IEEE floating point format: http://en.wikipedia.org/wiki/Binary64 It uses 52 bits for the mantissa (fractional part) which gives it an effective precision of 53 bits, equal to about 16 decimal digits of precision. The error you're getting is in the 17th digit - no surprise at all. -Gerry On 2010-12-19 , at 09:55 , Anthony Pace wrote: > trace(Number('1992.2')); > > //why does it output 1992.3 > //I am assuming I am missing something pretty obvious > ___ > Flashcoders mailing list > Flashcoders@chattyfig.figleaf.com > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders