Note that there are some explanatory texts on larger screens.

plurals
  1. PO1136: Incorrect number of arguments. Expected 0. on var ourShip:ship = new ship(stage);
    primarykey
    data
    text
    <p>Hi guys i am new to programming, I was following a tutorial on <a href="http://asgamer.com/2009/as3-flash-games-for-beginners-character-movement-handling-multiple-keypresses" rel="nofollow">As3 Flash Games</a></p> <p>I came across a code in which it was written </p> <pre><code>var ourShip:ship = new ship(stage); </code></pre> <p>But it gave an error</p> <pre><code>1136: Incorrect number of arguments. Expected 0. </code></pre> <p>I believe that the error it right but then what about the comments that the tutorial was awesome !</p> <p>The as file which includes this code has in it</p> <pre><code>package { //list of our imports these are classes we need in order to //run our application. import flash.display.MovieClip; import flash.display.Stage; //our Engine class it extends MovieClip public class engine extends MovieClip { //our constructor function. This runs when an object of //the class is created public function engine() { //create an object of our ship from the Ship class var ourShip:ship = new ship(stage); //add it to the display list stage.addChild(ourShip); ourShip.x = stage.stageWidth / 2; ourShip.y = stage.stageHeight / 2; } } } </code></pre> <p>Also to tell that i changed the senocular package from</p> <pre><code>package come.asgamer.....{} </code></pre> <p>to</p> <pre><code>package utils{} </code></pre> <p>I did this as i made a single folder named utils which has senocular action script in it</p> <p>I thought mabye the problem related to this</p> <p>By the way if i change </p> <pre><code>var ourShip:ship = new ship(stage); </code></pre> <p>to</p> <pre><code>var ourShip:ship = new ship(); </code></pre> <p>There is no result which means flash player displays the ship in middle as it is said</p> <p>Ship action script file : </p> <pre><code>package { import flash.display.MovieClip; import utils.KeyObject; import flash.ui.Keyboard; import flash.display.Stage; import flash.events.Event; public class ship extends MovieClip { private var stageRef:Stage; private var key:KeyObject; public function Ship(stageRef:Stage) { this.stageRef = stageRef; key = new KeyObject(stageRef); addEventListener(Event.ENTER_FRAME, loop, false, 0, true); } public function loop(e:Event) : void { if (key.isDown(Keyboard.LEFT)) x -= 2; else if (key.isDown(Keyboard.RIGHT)) x += 2; if (key.isDown(Keyboard.UP)) y -= 2; else if (key.isDown(Keyboard.DOWN)) y += 2; } } } </code></pre> <p>Note : I completed the tutorial</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload