A Flash Developer Resource Site

# Thread: what is Marital numbers code in ActionScript 3

1. ## what is Marital numbers code in ActionScript 3

hi
what is Marital numbers and odd numbers code in ActionScript 3

Marital numbers is : 0 2 4 6 8 10 12 .....
odd numbers is : 1 3 5 7 9 11 13 ....

i want do this :

var i:Marital numbers = Math.randomRange(0,20)
var hdd numbers = Math.randomRange(0,20)

2. how can i do this :

var i:Marital numbers = Math.randomRange(0,20)
var hdd numbers = Math.randomRange(0,20)
i > h ( " i " must be > "h")

3. If you're trying to randomly generate an even or an odd number there's a simple way to do it. Basically just create a recursive function that will keep calling itself until it gets the proper number. This is a dirty way to do it however. Another way would be to use the original random number generator function. It basically generates a number between 0 to 1. With that you'd have to multiply it by the max number. Then you can round the number to the closes proper value. This is how I'd handle it.

Code:
i > h ( " i " must be > "h")
This would be a starting point. It could be a problem if i is ever = to 20 however.
Code:
hdd numbers = Math.randomRange(i,20)

4. thanks swak you always help me
but i am sorry
can you please edit my file

5. i found this link but i tired to get any thing:

http://lab.kapit.fr/skin/frontend/de.../MathUtil.html

6. I can't use swish. So I can't open your 'math code.swi' file. If you could point me to a Swish installer I could use then that would be different but it seems broken.

Also, Marital in english has to do with marriage. So using that word here is confusing. After looking at things it looks like you mean the word 'even'. If you're confused by a word I suggest you use the search in google like this: "define: marital".

I've created something that should do it:
Code:
function generateNum(range:Array, isEven:int=0):int {
//isEven should be == 0 for even numbers and == 1 for odd
var num:Number = range[0]+Math.random()*range[1];
return (int(num)%2==isEven?Math.floor(num):Math.ceil(num));
}

var even:int = generateNum([0,20],0);
var odd:int = generateNum([0,even],1);
The only problem with this is if even becomes 0. It will end up with both even and odd being 0.

7. thanks swak
now it working fine
and excuse me for my bad english language

8. No problem, the link you supplied didn't work. It was shortened. Could you fix it please?

9. Thanks, that got it working.

10. my respect for you swak

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

 » Home » Movies » Tutorials » Submissions » Board » Links » Reviews » Feedback » Gallery » Fonts » The Lounge » Sound Loops » Sound FX » About FK » Sitemap