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 6068383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:42:33+00:00 2026-05-23T09:42:33+00:00

I’m an AS3 noob who is trying trying to get more comfortable with passing

  • 0

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…

package{
import flash.display.*;
public class Main extends Sprite{ 
        public function Main(){

    var square_commands:Vector.<int> = new Vector.<int>(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.<Number> = new Vector.<Number>(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.<int>,b:Vector.<Number>){
import flash.display.*;
    graphics.beginFill(0x442266);//set the color
    graphics.drawPath(a, b);
}
}
}

However, when I divide up the code into two AS3 files and try to pass the arguments to the function as follows…

package{
import flash.display.*;
public class Main extends Sprite{ 
        public function Main(){

    var square_commands:Vector.<int> = new Vector.<int>(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.<Number> = new Vector.<Number>(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);
}
}
}

and…

package{
import flash.display.*;
public class Fill extends Sprite{
public function Fill(a:Vector.<int>,b:Vector.<Number>){
    graphics.beginFill(0x442266);//set the color
    graphics.drawPath(a, b);
}
}
}

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);

Could someone please explain how I need to pass the arguments square_commands and square_coord into the function in the second AS3 file?

Thanks in advance for all the help!!!

  • 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-23T09:42:34+00:00Added an answer on May 23, 2026 at 9:42 am
    // main.as
    package{
      // good practice is to declare all imports in one spot and at the top of the class.
      import flash.display.*;
      public class Main extends Sprite{ 
        public function Main(){
          var square_commands:Vector.<int> = new Vector.<int>(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.<Number> = new Vector.<Number>(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; 
    
    
          // notice we are passing the parameters to the constructor of the Fill class
          var fill = new Fill(square_commands, square_coord);
        }
      }
    }
    
    
    
    // Fill.as
    package{
      import flash.display.*;
      public class Fill extends Sprite{
    
        // A function with the same name of the class file is the constructor.
        // A constructor will be called every time the new operator is called like I did in main.
        public function Fill(a:Vector.<int>,b:Vector.<Number>){
          graphics.beginFill(0x442266);//set the color
          graphics.drawPath(a, b);
        }
      }
    }
    

    I suggest you read up on OOP and learn it if you are going to do lots of coding.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
In my XML file chapters tag has more chapter tag.i need to display chapters
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.