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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:32:22+00:00 2026-05-24T09:32:22+00:00

I wrote a singleton class to keep track of some variables across my application.

  • 0

I wrote a singleton class to keep track of some variables across my application.

I am getting a syntax error that I can’t figure out, I am sure that I am missing something simple but it’s been one of those days. Anyone see something wrong with my code?

The error is 1061: Call to a possibly undefined method setResult through a reference with static type Class.

My function in my singleton class

public function setResult(resultNumber:int, value:int): void
    {
        switch(resultNumber)
        {
            case 2: { this.result2 = value; break; }
            case 3: { this.result3 = value; break; }
            case 4: { this.result4 = value; break; }
            case 5: { this.result5 = value; break; }
            case 6: { this.result6 = value; break; }
            case 7: { this.result7 = value; break; }
            case 8: { this.result8 = value; break; }
            case 9: { this.result9 = value; break; }
            case 10: { this.result10 = value; break; }
            case 11: { this.result11 = value; break; }
            case 12: { this.result12 = value; break; }
            case 13: { this.result13 = value; break; }
            case 14: { this.result14 = value; break; }
        }
    }

My function call in my mxml page

            if(chkBox1.selected == true)
            {
                utils.Calculation.setResult(2,1);
            }

Thanks in advance for any 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-24T09:32:22+00:00Added an answer on May 24, 2026 at 9:32 am

    Assuming you singleton is the Calculation class, are you missing your getInstance call?

    utils.Calculation.getInstance().setResult(2, 1);
    

    A good actionscript singleton pattern:

    package com.stackOverflow
    {
        public class MySingleton
        {
            public function MySingleton(lock:Class)
            {
                if(lock != SingletonLock)
                    throw new Error("This class cannot be instantiated, it is a singleton!");
            }
            private static var mySingleton:MySingleton;
    
            public static function getInstance():MySingleton{
                if(mySingleton==null)
                    mySingleton = new MySingleton(SingletonLock);
                return mySingleton;
            }
            public function setResult(resultNumber:int, value:int): void{
            //...
            }
        }
    }
    class SingletonLock{}
    

    Edit: getInstance() example for the Calculation class:

    private static var calculation:Calculation;
    public static function getInstance():Calculation{
        if(calculation==null)
            calculation = new Calculation(SingletonLock);
        return calculation;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote a singleton class to keep track of some variables across my application.
I wrote a class in charge of keeping track of error messages, which uses
Say I have a singleton-ish, factory-ish, reflection-ish class that receives some input, and spits
I wrote a windows service using VB that read some legacy data from Visual
I wrote myself a little downloading application so that I could easily grab a
I wrote an application that currently runs against a local instance of MySql. I
I created a Singleton class in c#, with a public property that I want
I want to write a java class that can be instantiated only 5 times
I am trying to create a persistent and shared variable that will keep track
I cannot figure out why I keep getting a null ref on filename when

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.