Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 06-03-2007, 04:02 AM   #1
wusj
Registered User
 
Join Date: Jun 2006
Posts: 28
Red face argument number error in learning AS3 Cookbook

I have a problem in Actionscript(Flex 2),Problems:1137: Incorrect number of arguments. Expected no more than 0 in line 6.Thanks,
Code:
package {
    import flash.display.Sprite;
    public class ExampleApplication extends Sprite
    {
        public function ExampleApplication(  ) {
         	var average:Number = average (1, 2, 5, 10, 8, 20);
        }
        private function average(  ):Number {
			var sum:Number = 0;
			
			// Loop through each of the elements of the arguments array, and 
			// add that value to sum.
			for (var i:int = 0; i < arguments.length; i++) {
			sum += arguments[i];
			}
			// Then divide by the total number of arguments
			return sum/arguments.length;
		}
    }
}

Last edited by wusj; 06-03-2007 at 04:12 AM.
wusj is offline   Reply With Quote
Old 06-03-2007, 04:18 AM   #2
Flash Gordon
rather be programming
 
Flash Gordon's Avatar
 
Join Date: Feb 2005
Location: City of Angels
Posts: 10,140
Default

oh, you need the ...arguments in the params place. see here: http://www.senocular.com/flash/tutor...3withflashcs3/

ActionScript Code:
// Using the ...(rest) parameter function passAnything(...statements):void {     trace(statements.length +": "+ statements); } passAnything(); // traces 0: passAnything(1); // traces 1: 1 passAnything("a", true, 0); // traces 3: a,true,0

I take it you are working out of the AS 3.0 cookbook judging by the name of your class. If so, how did you get the first couple of examples to work. (see my post here too).
__________________
trace("Good bye Flash.") Log.i(TAG, "Hello Droid");

Last edited by Flash Gordon; 06-03-2007 at 04:31 AM.
Flash Gordon is offline   Reply With Quote
Old 06-03-2007, 07:18 AM   #3
wusj
Registered User
 
Join Date: Jun 2006
Posts: 28
Default thank you ,Flash Gordon !

thank you ,Flash Gordon !
It is OK
is something wrong in ActionScript3.0 Cookbook?
wusj is offline   Reply With Quote
Old 06-03-2007, 07:19 AM   #4
Flash Gordon
rather be programming
 
Flash Gordon's Avatar
 
Join Date: Feb 2005
Location: City of Angels
Posts: 10,140
Default

I can't get the first couple of examples to work. Maybe it is just me, dunno.
__________________
trace("Good bye Flash.") Log.i(TAG, "Hello Droid");
Flash Gordon 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
Useful Utilities..cookies, key combination,etc MichaelxxOA Projectors and CDs 147 11-08-2013 11:28 AM
Image Distortion ds.pixeled Other Flash General Questions 4 11-03-2007 06:57 AM
AS3 learning curve jay_12975 ActionScript 3.0 2 02-02-2007 12:07 AM
Distorting a Image Cazz ActionScript 2.0 6 10-01-2006 03:21 PM
getting numbered values from array linckx ActionScript 1.0 (and below) 14 06-23-2003 11:21 PM


All times are GMT. The time now is 06:05 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.