• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

error 1137

New Here ,
Oct 07, 2012 Oct 07, 2012

Copy link to clipboard

Copied

i am really really mad because i have been trying to make a turret game from a series of 30 tutorials and im on the 13th one and the code is messing up and i re did the code 2 times wich was over 2 hours of doing a code that works for this guy just fine and i need it to work, http://www.youtube.com/watch?v=SMo5FU8H_d8

my code is

package  {

 

          import flash.display.Sprite;

          import Explosion;

          import ReusableCode.myMaths;

          import flash.events.Event;

 

          public class ExplosionChain extends Sprite {

 

                    // variables

                    private var lifespan:int;

                    private var birthrate:Number;

                    private var blastRadius:Number;

                    private var minBlast:int;

                    private var maxBlast:int;

                    private var birthCounter:Number=1;

                    public function ExplosionChain(l:int=20, b:Number=0.5, br:Number=20, minB:int=5, maxB:int=20) {

                              // constructor code

                              lifespan=1;

                              birthrate=b;

                              blastRadius = br;

                              minBlast=minB;

                              maxBlast=maxB;

                              addEventListener(Event.ENTER_FRAME, update)

                    }

 

                    public function update(e:Event) {

                              lifespan--;

                              if (lifespan>0) {

                                        while(birthCounter>=0) {

                                                  birthCounter-=birthrate;

                                                  var ex = new Explosion(minBlast+(maxBlast-minBlast)*Math.random());

                                                  ex.rotation = Math.random()*360;

                                                  myMaths.moveFoward(ex, Math.random()*blastRadius);

                                                  addChild(ex);

                                        }

                                        birthCounter+=1;

                              }else if (numChildren==0) {

                                        parent.removeChild(this);

                                        }

                              }

                    }

          }

the error says

/Users/baileypandiscio/Desktop/Turret Game/ExplosionChain.as, Line 331137: Incorrect number of arguments.  Expected no more than 0.

and the guy's code from the tutorial works just great for him. please help.

TOPICS
ActionScript

Views

2.0K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Oct 07, 2012 Oct 07, 2012

There's the problem... in the Explosion class, the constructor does not take arguments...

    public function Explosion() {

But in your other class you are calling that class function using arguments...

    var ex = new Explosion(minBlast+(maxBlast-minBlast)*Math.random() );

That red stuff is not accomodated by the class.

Votes

Translate

Translate
LEGEND ,
Oct 07, 2012 Oct 07, 2012

Copy link to clipboard

Copied

Which is line 33?  What does the function that it calls look like?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 07, 2012 Oct 07, 2012

Copy link to clipboard

Copied

line 33 is var ex = new Explosion(minBlast+(maxBlast-minBlast)*Math.random());

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 07, 2012 Oct 07, 2012

Copy link to clipboard

Copied

What does the function/class that it calls look like?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 07, 2012 Oct 07, 2012

Copy link to clipboard

Copied

if u mean what is the code called Explosion that it plays rapidly if it works it is

package  {

          import flash.display.Sprite;

          import fl.transitions.Tween;

          import fl.transitions.TweenEvent;

          import fl.transitions.easing.*;

          import flash.events.Event;

 

          public class Explosion extends Sprite {

 

                    //make tween variables

                    private var tweenAlpha:Tween;

                    private var tweenSize:Tween;

 

                    public function Explosion() {

                              // constructor code

                              // use the graphics of this sprite to draw a circle

                              graphics.beginFill(0xFFFFFF);

                              graphics.drawCircle(0,0,10);

                              graphics.endFill();

                              // add an event listener for when the explosion is added to the screen

                              addEventListener(Event.ADDED_TO_STAGE, Init);

                    }

 

                    private function Init(e:Event) {

                              // set up alpha tween

                              tweenAlpha = new Tween(this, "alpha", Regular.easeInOut, 1, 0, 20);

                              tweenAlpha.addEventListener(TweenEvent.MOTION_FINISH, removeExplosion);

                              // set up the tween to scale the explosion

                              tweenSize = new Tween(this, "scaleX", Regular.easeInOut, 0, 1, 10);

                              tweenSize.addEventListener(TweenEvent.MOTION_CHANGE, applyScale);

                    }

 

                    private function applyScale(t:TweenEvent) {

                              scaleY = scaleX;

                    }

 

                    private function removeExplosion(t:TweenEvent) {

                              Sprite(parent).removeChild(this);

                    }

          }

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 07, 2012 Oct 07, 2012

Copy link to clipboard

Copied

There's the problem... in the Explosion class, the constructor does not take arguments...

    public function Explosion() {

But in your other class you are calling that class function using arguments...

    var ex = new Explosion(minBlast+(maxBlast-minBlast)*Math.random() );

That red stuff is not accomodated by the class.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 07, 2012 Oct 07, 2012

Copy link to clipboard

Copied

O.O im 13 and am not too good with as3 but im amazing with as2  and im trying to learn as3 and its a lot more confusing but way more usefull. so what do i need to do to the explosion class to get it working?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 07, 2012 Oct 07, 2012

Copy link to clipboard

Copied

so do i need to make     public function Explosion() { not public or something? excuse me if i do not sound verry knowlegable about this topic, i just started as3 yesterday and want to make a game to impress my teacher

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 07, 2012 Oct 07, 2012

Copy link to clipboard

Copied

LATEST

If you want to be able to call the Explosion class from other classes, then you need to keep it as a public class/function.

For now what you should do to get rid of the error is to remove the argument(s) from the function call on line 33...

  var ex = new Explosion();

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 07, 2012 Oct 07, 2012

Copy link to clipboard

Copied

and

import flash.events.MouseEvent;

stage.addEventListener(MouseEvent.CLICK, explode);

function explode(m:MouseEvent) {

          var e = new Explosion();

          var ex = new ExplosionChain();

          e.x = mouseX

          e.y = mouseY

          addChild(e);

}

is the fuction for the stage for when you click, it makes doezens of little explosions

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines