Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 03-06-2007, 07:07 AM   #1
Senior Member
Join Date: Dec 2005
Location: india
Posts: 206
Default Math.random

Hi all,

I am trying to generate a random number. Code was written with AS2. Now I am trying to convert it to AS3

var anim:Number
anim = Math.random(1)*10;//error at this line: ArgumentError: Error #1063: Argument count mismatch on Math$/random(). Expected 0, got 1.
animround = Math.round(anim);
veiky is offline   Reply With Quote
Old 03-06-2007, 08:47 AM   #2
Assertnfailure's Avatar
Join Date: Dec 2005
Location: LA, California
Posts: 838

don't put a number inside the parenthesis for Math.random();

Hence why the argument error said "Expected 0, got 1."
Assertnfailure is offline   Reply With Quote
Old 03-06-2007, 03:44 PM   #3
patrick mantout
Registered User
Join Date: Dec 2006
Posts: 33

to get a random number between 'minimum' and 'maximum'

        private function rand(minimum:Number, maximum:Number):Number {
            return Math.floor(minimum + Math.random()*(maximum - minimum + 1));
I hope it will help you
patrick mantout is offline   Reply With Quote

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Timing Intervals unsurreal Simple Stuff (Newbies) 1 05-07-2005 10:32 PM
Math.random() scaramanga ActionScript 1.0 (and below) 1 03-04-2004 08:16 AM
math.random with mc red-eye ActionScript 1.0 (and below) 2 07-22-2003 04:54 PM
Math.random() soc ActionScript 1.0 (and below) 3 10-28-2002 04:12 AM
can I control Math.random ? vosgien ActionScript 1.0 (and below) 3 05-30-2002 08:00 AM

All times are GMT. The time now is 12:14 AM.

Follow actionscriptorg on Twitter


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2015, 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.