actionscript 3 - 1136: Incorrect number of arguments. Expected 0.‎ AS3 Flash Cs4 -


Actually I am working through a book .. its Foundation Action Script 3.0 animation, moving things forward.

Now I'm on Chapter 9 - Finding Collision I get 1135 errors on two lines of my code, tell me I have a wrong number of arguments Can someone help me why this is It is possible?

  package {import flash.display.Sprite; Import flash.events.Event; Public Class Bubbles Sprite (Private World Balls: Array; Private Miscellaneous Number: Number = 10; Private War Centerball: Ball; Private Bounce: Number = -1; Personal Var Spring: Number = 0.2; Public Function Bubbles () {init ( );} Private work init (): zero {balls = new array (); CenterBall = new ball (100, 0xcccccc); addChild (centerBall); CenterBall.x = stage.stageWidth / 2; CenterBall.y = step. / 2; (Var i: uint = 0; i & lt; numballs; i ++) {var ball: ball = new ball (math.rendum ()) * 40 + 5, Math. Random (* * 0xffffff); Ball.x = Math.Random () * Stage. Stagewidth; Ball.y = Math.Rendum () * Step .Stage High; Ball.vx = Math.random () * 6-3; Ball.vy = Math.random () * 6-3; AddChild (ball); Balls.push (ball); } AddEventListener (Event.ENTER_FRAME, onEnterFrame); } Private Function Printerframe (Event: Event): For Zero {(var i: uint = 0; i & lt; numballs; i ++) {var ball: ball = ball [i]; Move (ball); Var DX: number = ball.x - centerball.x; Var dye: number = ball. Y - center ball; Var dist: number = math.Sqrt (dx * dx + dy * dy); Var minDist: number = ball. Triangle + centerbal RDS; If (District  step.stage width) {ball.x = stage.stageWidth - ball.radius; Ball.vx * = Bounce; } And if (ball.x - ball.radius <0) {ball.x = ball.radius; Ball.vx * = Bounce; } // Problem here: if (ball.y + ball.radius> stage.stageHeight) {ball.y = stage.stageHeight - ball.radius; Ball.vy * = Bounce; } And if (ball-y-ball radius & lt; 0) {ball.y = ball.radius; Ball.vy * = Bounce; }}}}  

I have indicated the rows with which I have trouble.

The following lines are guilty.

  centerbal = new ball (100, 0xcccccc); Var Ball: Ball = New Ball (Math. Random) * 40 + 5, Math. Random (* * 0xffffff);  

You are trying to argue the ball constructor who takes zero arguments. Change them

  centerBall = new ball (); Var ball: ball = new ball (); Respectively  

and this will work if you really want to pass the initial details, then create a Ball.as file and assign it to the movie clip on the forum. Please. Now, to accept these two arguments, declare the ball class constructor and initialize the variable (radius and color) within the manufacturer.


BallS will appear something like this

  package {extends public square ball movie clips {public function ball ( R: number, color: uint) {this.radius = r; This.color = col; }}}  

Comments