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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T18:41:06+00:00 2026-06-18T18:41:06+00:00

The code illustrates the problem pretty well, I’ve cut everything unrelated out. Create 2-4

  • 0

The code illustrates the problem pretty well, I’ve cut everything unrelated out.

Create 2-4 kinsmen when the game starts

function createInitialKinsmen()
{
    for (var k:int = 1; k < 3 + Math.round(Math.random() * 2; k++)
    {
        if (k == 1)
        {
            createKinsmen(0);
            trace ("player");
        }
        else
        {
            createKinsmen(1);
            trace ("starting kinsmen");
        }
    }
}

Kinsmen creation function

function createKinsmen(arrivalTypeVar:int)
{
    var newKinsmen = new kinsmen;
    listPanel.kinsmenDivider.addChild(newKinsmen);
    totalKinsmen++;
    totalKinsmenAlive++;
    newKinsmen.name = "kinsmen" + totalKinsmen;
    newKinsmen.arrivalType = arrivalTypeVar;
}

Kinsmen class

public class kinsmen extends MovieClip
{
    var arrivalType:int;
    function kinsmen()
    {
        trace(this.name);
        if (this.arrivalType = 0)
        {
            trace("player");
        }
        if (this.arrivalType = 1)
        {
            trace("starting kinsmen");
        }
    }
}

The output should say:

kinsmen1
player
player
kinsmen2
starting kinsmen
starting kinsmen
kinsmen3
starting kinsmen
starting kinsmen
kinsmen4
starting kinsmen
starting kinsmen

But instead says:

kinsmen1
player
player
kinsmen2
player
starting kinsmen
kinsmen3
player
starting kinsmen
kinsmen4
player
starting kinsmen

Which means that the arrivalType variable isn’t being passed on. It seems to be hard-coded variables can be passed though thus at the moment I have a square with alpha 0 inside the kinsmen movieclip and it’s x position determines the value of arrivalType in the constructor but this surely can’t be good practice, is there a better way of doing this?

  • 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-18T18:41:07+00:00Added an answer on June 18, 2026 at 6:41 pm

    I think you just want to modify your constructor function for the kinsmen class to accept a parameter for the arrivalType and the name.

    What you’re currently doing is constructing a new kinsmen object and afterwards setting the arrivalType and the name on that object. So when the constructor code runs, the arrivalType is the default value of an int which is 0.

    Modify your constructor function like this in the kinsmen class:

    function kinsmen(arrivalType:int, name:String)
    {
        this.name = name;
        this.arrivalType = arrivalType;
        if (this.arrivalType == 0)
        {
            trace("player");
        }
        if (this.arrivalType == 1)
        {
            trace("starting kinsmen");
        }
    }
    

    And modify your createKinsmen() function so that it passes in a value for the arrivalType to the constructor method, instead of setting the arrivalType and name after the object is created:

    function createKinsmen(arrivalTypeVar:int)
    {
        totalKinsmen++;
        totalKinsmenAlive++;
        var newKinsmen = new kinsmen(arrivalTypeVar, "kinsmen" + totalKinsmen);
        listPanel.kinsmenDivider.addChild(newKinsmen);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is the smallest amount of code that clearly illustrates my problem: <html> <body>
This code illustrates my problem: //Constructor public ReadFormat(String path, int nic) throws IOException{ this.path
Here's a minimum code example that illustrates the problem: #include <iostream> class Thing {
The following code illustrates my problem: public class Person : (INotifyPropertyChanged) // INPC only
The following C code illustrates a problem I'm seeing on Linux 2.6.30.5-43.fc11.x86_64: #include <sys/types.h>
Here is some sample code that illustrates the problem. It compiles and runs correctly,
This code below best illustrates my problem: The output to the console (NB it
I am struggling with a Scala implicit conversion problem. The following code snippet illustrates
I've got a problem with inheritance and generics. This is the code that illustrates
Here is a little sample code which illustrates my problem: http://jsfiddle.net/wsytR/2/ If you change

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.