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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:39:00+00:00 2026-06-18T05:39:00+00:00

I got this class, let’s call it: Klass. The class Klass has a parameter

  • 0

I got this class, let’s call it: Klass.

The class Klass has a parameter for its constructor that is an array with a default value of null.

I create an object of the class Klass inside another class, lets call it: “MotherClass”.

Now is when it gets weird, after I instance the object Klass, the constructor of Klass gets called again, just right after the constructor of the MotherClass ends (I placed a breakpoint and I followed step by step), with null constructor parameters.

The thing is, I don’t have the stack trace of anything that is calling the constructor of Klass for the second time, no clue what could be calling that constructor again…

Any ideas?

Thanks.

(Klass implements an interface, and I’m making an instance using an array, not sure if that is affecting anything)

added code as requested:

this is the class MotherKlass:

public class Unit extends EntityVO{

    public function Unit(level:int = 1)
            {
                //init vars and stuff
                //...
                //

                initLevelData();
                applyLevel = level;

            }

            private function initLevelData():void {

                levelData[1] = [500,  [[Spawn, this.entityToSpawn.type, this.entityToSpawn.level, 120]], "unit_level1"];
                levelData[2] = [1000, [[Spawn, this.entityToSpawn.type, this.entityToSpawn.level,  90]], "unit_level2"];
                levelData[3] = [2000, [[Spawn, this.entityToSpawn.type, this.entityToSpawn.level,  80]], "unit_level3"];
                levelData[4] = [5000, [[Spawn, this.entityToSpawn.type, this.entityToSpawn.level,  60]], "unit_level4"];

            }

            override public function set applyLevel(level:int):void {

                power     = power / maxPower * levelData[level][0]; 
                maxPower  = levelData[level][0];
                behavior  = levelData[level][1];

                for (var i:int = 0; i < behavior.length; i ++){
                    _behaviorSteps[i] = new behavior[i][0](behavior[i].slice(1));
                    _behaviorReqs.push(_behaviorSteps[i].req);
                }

            }
        }
    }   
}

and this is Klass:

public class Spawn {

    public class Spawn implements IBehavior
        {
            private var _entityType:String;
            private var _entityLevel:int;
            private var _spawnRate:int;

            public function Spawn(params:Array = null){
                //had to put the if because of the second weird call to the constructor with null
                if(params){
                    _entityType = params[0];
                    _entityLevel = params[1];
                    _spawnRate  = params[2];
                }
            }
        }
    }
}
  • 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-06-18T05:39:01+00:00Added an answer on June 18, 2026 at 5:39 am

    I’m receiving an instance of the class Unit throught Cirrus, and using RegisterClassAlias to deserialize the object. When I do that, seems like an instance of Spawn must be automatically instantiated for some reason. That is why you cant pass ojbects without default arguments. In this case, it throws an error because I’m using (params[0]) the argument that is null. I use Cirrus in other parts of my code, and it works ok because there are all ints and strings in their parameters constructors.

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

Sidebar

Related Questions

I've got this class, let's call it Refund (because that's what it's called). I
I've got a class (let's call it MyWidget for now) that extends View in
I´ve got this CRac class and it´s giving me some problems with its members.
I've got this code in the InitInstance function of a class that extends WinApp:
I've got a class representing an interval. This class has two properties start and
Let's say i got this: public class Foo{ public string Bar; } Then i
Let say I got this page: <body> <h1>Hello!</h1> <div class=wrapper> <div class=anotherclass> <h1>Another heading
I got this Accelerometer class that holds values of accelerometer and I can acces
Let's say I've got some class that observe, and a class that is observed,
Let's say I got the class name with get_class($this) within an abstract class method.

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.