Thanks a million Helen - I have been sitting for hours trying to figure this one out - doesnt help being bunged up with the cold so few brain cells actually functioning!!
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Helen Triolo Sent: 06 March 2006 14:13 To: Flashcoders mailing list Subject: Re: [Flashcoders] Strange behaviour from modulus operator Because _x is not necessarily an integer, vValue1 is not guaranteed to be an integer either, which it must be for modulo to return the result you want. Force it to be with var vValue1 = Math.round(passed_MC._x - this.Maze_Horizontal_offset); and it should work as you expect. Helen -- http://flash-creations.com http://i-technica.com Paul Steven wrote: >Experiencing a strange problem using the modulus operator. > >Inside a function I have the following code: > >var vValue1 = passed_MC._x - this.Maze_Horizontal_offset; >var vValue2 = 36; > >var vTheResult = vValue1 % vValue2; > >trace ("vValue1 = " + vValue1); >trace ("vTheResult = " + Number(vTheResult)); > >And here are the results I am getting from the trace statements: > >vValue1 = 324 >vTheResult = 5.6843418860808e-14 > >---------------- > >Surely it should give me a result of zero as 36 goes into 324 exactly 9 >times. > >The weird thing is if I just hard code the values as follows, it works > >var vValue1 = 324; >var vValue2 = 36; > >var vTheResult = vValue1 % vValue2; > >trace ("vTheResult = " + Number(vTheResult)); > >----------------- > >And here is the result of the trace statement: > >vTheResult = 0 > >I am therefore totally confused!!! > >Any help much appreciated. I am publishing for Flash 7 with Actionscript 1.0 > >Thanks > >Paul > > _______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com _______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com