Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 03-06-2007, 06:07 AM   #1
veiky
Senior Member
 
Join Date: Dec 2005
Location: india
Posts: 204
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


Code:
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.
trace(anim);
animround = Math.round(anim);
trace(animround);
)
veiky is offline   Reply With Quote
Old 03-06-2007, 07:47 AM   #2
Assertnfailure
as[org].addListener(this)
 
Assertnfailure's Avatar
 
Join Date: Dec 2005
Location: LA, California
Posts: 837
Default

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, 02:44 PM   #3
patrick mantout
Registered User
 
Join Date: Dec 2006
Posts: 33
Default

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

Code:
        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
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 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 07: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 03: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:38 PM.

///
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.