Note that there are some explanatory texts on larger screens.

plurals
  1. PONoob question regarding passing arguments into a function located in a separate AS3 file
    text
    copied!<p>I'm an AS3 noob who is trying trying to get more comfortable with passing arguments into functions. Can someone please help me understand why when the following code is all in one AS3 file as seen below it works and draws the purple square...</p> <pre><code>package{ import flash.display.*; public class Main extends Sprite{ public function Main(){ var square_commands:Vector.&lt;int&gt; = new Vector.&lt;int&gt;(5,true); square_commands[0] = 1;//moveTo square_commands[1] = 2;//lineTo square_commands[2] = 2; square_commands[3] = 2; square_commands[4] = 2; var square_coord:Vector.&lt;Number&gt; = new Vector.&lt;Number&gt;(10,true); square_coord[0] = 20; //x square_coord[1] = 10; //y square_coord[2] = 50; square_coord[3] = 10; square_coord[4] = 50; square_coord[5] = 40; square_coord[6] = 20; square_coord[7] = 40; square_coord[8] = 20; square_coord[9] = 10; Fill(square_commands, square_coord); } public function Fill(a:Vector.&lt;int&gt;,b:Vector.&lt;Number&gt;){ import flash.display.*; graphics.beginFill(0x442266);//set the color graphics.drawPath(a, b); } } } </code></pre> <p>However, when I divide up the code into two AS3 files and try to pass the arguments to the function as follows...</p> <pre><code>package{ import flash.display.*; public class Main extends Sprite{ public function Main(){ var square_commands:Vector.&lt;int&gt; = new Vector.&lt;int&gt;(5,true); square_commands[0] = 1;//moveTo square_commands[1] = 2;//lineTo square_commands[2] = 2; square_commands[3] = 2; square_commands[4] = 2; var square_coord:Vector.&lt;Number&gt; = new Vector.&lt;Number&gt;(10,true); square_coord[0] = 20; //x square_coord[1] = 10; //y square_coord[2] = 50; square_coord[3] = 10; square_coord[4] = 50; square_coord[5] = 40; square_coord[6] = 20; square_coord[7] = 40; square_coord[8] = 20; square_coord[9] = 10; Fill(square_commands, square_coord); } } } </code></pre> <p>and...</p> <pre><code>package{ import flash.display.*; public class Fill extends Sprite{ public function Fill(a:Vector.&lt;int&gt;,b:Vector.&lt;Number&gt;){ graphics.beginFill(0x442266);//set the color graphics.drawPath(a, b); } } } </code></pre> <p>Flash CS5 gives me an error message 1137 saying that it was expecting only 1 argument in the code line --> Fill(square_commands, square_coord);</p> <p>Could someone please explain how I need to pass the arguments square_commands and square_coord into the function in the second AS3 file?</p> <p>Thanks in advance for all the help!!!</p>
 

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