Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 07-11-2008, 10:45 PM   #1
pelachrum
mighty mouse
 
Join Date: Oct 2002
Location: New York City
Posts: 290
Default finding multiple of a number

how would you write in actionscript what in plain English sounds like:
if i equals 7 or a multiple of 7
ActionScript Code:
if (i==7 || ??????)
to state that in a literal (although limiting) form it would look like this
ActionScript Code:
if (i==7 || i==14 || i==21 || i==28)
pelachrum is offline   Reply With Quote
Old 07-11-2008, 11:23 PM   #2
eddiewireless
Chicken and perks!
 
eddiewireless's Avatar
 
Join Date: Jan 2007
Location: Earth
Posts: 518
Send a message via MSN to eddiewireless
Default

that sounds a lil tricky, how far up do you wanna go? I guess you could use a loop to calculate the next multiple but you need to eventually stop it or your script will malfunction. (Infinite Loop)
eddiewireless is offline   Reply With Quote
Old 07-12-2008, 12:05 AM   #3
pelachrum
mighty mouse
 
Join Date: Oct 2002
Location: New York City
Posts: 290
Default

ok
let's keep it realistic then
up to 5
pelachrum is offline   Reply With Quote
Old 07-12-2008, 12:54 AM   #4
daveystew
Dave Stewart
 
daveystew's Avatar
 
Join Date: Aug 2005
Location: London
Posts: 770
Default

The operator (%) is built into most languages, and is called modulo:

var num = 235
var multiple = 5
var isMultiple:Boolean = num % multiple == 0
__________________
xJSFL | Creative | Technical
daveystew is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
tsunami tutorial (again!) - multiple columns! doobie ActionScript 1.0 (and below) 7 04-28-2007 02:47 AM
Random Number Generator, Help ? Mutty Other Flash General Questions 15 10-09-2006 04:16 PM
finding total number of frames in a movie clip bltrio ActionScript 2.0 2 04-24-2006 01:05 AM
Flash Number type and c# float and decimal types. Convertion problem within Flash. maglez ActionScript 2.0 2 06-02-2005 06:14 PM
Arrays, multiple if statements Rush152 Simple Stuff (Newbies) 2 01-25-2004 12:10 AM


All times are GMT. The time now is 03:20 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.