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

  • Home
  • SEARCH
  • 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 807085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T00:20:58+00:00 2026-05-15T00:20:58+00:00

i just know this is a dumb question, so excuse me in advance. i

  • 0

i just know this is a dumb question, so excuse me in advance.

i want to essentially classify a simple function in it’s own .as file. the function compares integers. but i don’t know how to call the class and receive a boolean return.

here’s my class

package
{
public class CompareInts
    {
    public function CompareInts(small:int, big:int)
        {
        compare(small, big);
        }

    private function compare(small:int, big:int):Boolean
        {
        if (small < big)
            return true;
            else
            return false;
        }
    }
}

so now i’d like to write something like this:

if (CompareInts(1, 5) == true). or output ‘true’ by writing trace(CompareInts(1, 5));

  • 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-15T00:20:58+00:00Added an answer on May 15, 2026 at 12:20 am

    You have 2 options:

    1) Make your compare function public and static.

    static public function compare(small:int,big:int):Boolean {
    {
        if (small < big)
            return true;
        else
            return false;
        }
    }
    

    And call it:

    CompareInts.compare(1,5);
    

    2) You don’t actually need a class. You can just use a function. As long as there’s only one public definition per AS file, you’ll be fine (by that I mean that at the “top” level you can have a public class, an interface, a public function, a public var or a public namespace. It won’t work if you try to have more than one.

    package {
        public function compare(small:int,big:int):Boolean {
        {
            if (small < big)
                return true;
            else
                return false;
        }
    }
    

    Or, you could inline this into a single line and ditch the class / function entirely (parens are not neccesary, I just added them for clarity):

    var compare:Boolean = (small < big);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is going to be a really dumb question, I just know it, but
This might be a dumb question. I think I already know the answer, just
I know this will seem like a dumb question but I'm just getting started
Yeah, I know this seems like a dumb question, its just a one-off hack
I know this may seem like a math question but i just saw this
I know this is a stupid question. But just out of curiosity, is there
I know this is simple, I just can't recall the best way to do
I know this is going to be something simple that I'm just missing somehow,
I just want to know why this doesn't work (I am trying to name
I just trying to know is this possible the function of MYSQL GROUP_CONCAT to

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.