Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 812455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T01:12:27+00:00 2026-05-15T01:12:27+00:00

(I have asked this before but I dont think I was direct enough with

  • 0

(I have asked this before but I dont think I was direct enough with my question and therefore it did not get resolved so here goes again!)

I am working through a book called Foundation Actionscript 3.0 Animation, making things move.

I am now on Chapter 9 – Collision Detection. On two lines of my code I get the 1135 error, letting me know that I have an incorrect number of arguments. I have highlighted the two areas in which this occurs with asterisks:

package 
{ 
import flash.display.Sprite; 
import flash.events.Event; 
public class Bubbles extends Sprite 
{ 
private var balls:Array; 
private var numBalls:Number = 10; 
private var centerBall:Ball; 
private var bounce:Number = -1; 

private var spring:Number = 0.2; 
public function Bubbles() 
{ 
init(); 
} 
private function init():void 
{ 
balls = new Array(); 
***centerBall = new Ball(100, 0xcccccc);*** 
addChild(centerBall); 
centerBall.x = stage.stageWidth / 2; 
centerBall.y = stage.stageHeight / 2; 
for(var i:uint = 0; i < numBalls; i++) 
{ 
***var ball:Ball = new Ball(Math.random() * 
40 + 5, 
Math.random() * 0xffffff);*** 
ball.x = Math.random() * stage.stageWidth; 
ball.y = Math.random() * stage.stageHeight; 
ball.vx = Math.random() * 6 - 3; 
ball.vy = Math.random() * 6 - 3; 
addChild(ball); 
balls.push(ball); 
} 
addEventListener(Event.ENTER_FRAME, onEnterFrame); 
} 
private function onEnterFrame(event:Event):void 
{ 
for(var i:uint = 0; i < numBalls; i++) 
{ 
var ball:Ball = balls[i]; 
move(ball); 
var dx:Number = ball.x - centerBall.x; 
var dy:Number = ball.y - centerBall.y; 
var dist:Number = Math.sqrt(dx * dx + dy * dy); 
var minDist:Number = ball.radius + centerBall.radius; 
if(dist < minDist) 
{ 
var angle:Number = Math.atan2(dy, dx); 
var tx:Number = centerBall.x + 
Math.cos(angle) * minDist; 
var ty:Number = centerBall.y + 
Math.sin(angle) * minDist; 
ball.vx += (tx - ball.x) * spring; 
ball.vy += (ty - ball.y) * spring; 
} 
} 
} 
private function move(ball:Ball):void
{ 
ball.x += ball.vx; 
ball.y += ball.vy; 
if(ball.x + ball.radius > stage.stageWidth) 
{ 
ball.x = stage.stageWidth - ball.radius; 
ball.vx *= bounce; 
} 
else if(ball.x - ball.radius < 0) 
{ 
ball.x = ball.radius; 
ball.vx *= bounce; 
} 
if(ball.y + ball.radius > stage.stageHeight) 
{ 
ball.y = stage.stageHeight - ball.radius; 
ball.vy *= bounce; 
} 
else if(ball.y - ball.radius < 0) 
{ 
ball.y = ball.radius; 
ball.vy *= bounce; 
} 
} 
} 
} 

I think this is due to the non-existance of a Ball.as, when reading the tutorial I assumed it meant that I had to create a movie clip of a ball on stage and then export it for actionscript with the class name being Ball, however when flicking back through the book I saw that a Ball.as already existed, stating that I may need to use this again later on in the book, this read:

package 
{ 
import flash.display.Sprite; 
public class Ball extends Sprite 
{ 
private var radius:Number; 
private var color:uint; 
public var vx:Number=0; 
public var vy:Number=0; 
public function Ball(radius:Number=40, color:uint=0xff0000) 
{ 
this.radius=radius; 
this.color=color; init(); 
} 
public function init():void 
{
 graphics.beginFill(color); 
graphics.drawCircle(0, 0, radius); 
graphics.endFill();
 }
 }
 }

This managed to stop all the errors appearing however, it did not transmit any of the effects from Bubbles.as it just braught a Red Ball on the center of the stage. How would I alter this code in order to work in favour of Bubbles.as?

Please Help! Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T01:12:27+00:00Added an answer on May 15, 2026 at 1:12 am

    It ran fine for me, however I needed to make some adjustments to the code you’ve provided – I noticed that from your Bubbles class you are trying to access Ball’s properties that are set as private (radius, color), so either set them public or create the proper getter/setter methods for that matter.

    public var radius:Number;
    public var color:uint;
    

    or if you want to use getter/setter functions

    private var _radius:Number;
    private var _color:uint;
    
    public function get radius():Number
    {
       return _radius;
    }
    public function set radius(val:Number):void
    {
       _radius = val;
    }
    
    public function get color():uint
    {
       return _color;
    }
    public function set color(val:uint):void
    {
       _color= val;
    }
    

    After that change was made, I just set Bubbles as my FLA document root, and bam!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have asked this before but I didn't get the question right so the
This question has to have been asked before, but I think the search terms
I am not sure if this was asked before but I have to do
This question has been asked before ( link ) but I have slightly different
This question may have been asked before, but I had trouble finding an answer,
I've asked this question before but I don't think I explained myself clearly so
Tried posting this before but it did not go through (i think) so if
I know this question has been asked here before, but I don't think those
I'm aware that variants of this question have been asked before, but I do
I realize this question is very likely to have been asked before, but I've

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.