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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:03:02+00:00 2026-06-17T13:03:02+00:00

Below are two 2D objects, Array and Vector. As you can see the information

  • 0

Below are two 2D objects, Array and Vector. As you can see the information described in both is identically. My game works flawlessly using the Array object, but with Vector is throws the following error:

[Fault] exception, information=RangeError: Error #1125: The index 10 is out of range 10. 

var _platformMap:Array = [
       [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],
       [00, 00, 10, 10, 10, 10, 10, 10, 10, 10],
       [10, 10, 10, 10, 10, 10, 00, 00, 00, 10],
       [10, 10, 10, 00, 00, 10, 10, 10, 10, 10],
       [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],
       [10, 10, 00, 00, 00, 00, 00, 10, 10, 10],
       [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],
       [00, 00, 00, 00, 00, 00, 00, 00, 00, 00]
     ];

var _platformMap:Vector.<Vector.<int>> = Vector.<Vector.<int>>(
        [
            Vector.<int>([10,10,10,10,10,10,10,10,10,10]), 
            Vector.<int>([00,00,10,10,10,10,10,10,10,10]), 
            Vector.<int>([10,10,10,10,01,01,01,10,10,10]), 
            Vector.<int>([10,10,10,00,10,10,10,10,01,10]), 
            Vector.<int>([10,10,10,00,10,10,01,01,01,00]), 
            Vector.<int>([10,10,10,10,01,01,01,01,01,10]), 
            Vector.<int>([00,00,00,00,00,10,10,10,10,10]), 
            Vector.<int>([00,00,00,00,00,00,00,00,00,00])
        ]
    );

I read about that Vector objects have runtime range checking (or fixed-length checking) besides Arrays. Could this be the problem?

public class TileCollisionController
{
    private var _softPlatformOpen:Boolean = true;
    private var _elevatorOpen:Boolean = true;

    public function TileCollisionController()
    {}

    public function platformCollision(gameObject:TileModel, platformMap:Vector.<Vector.<int>>, maxTileSize:uint, platform:uint):void
    {
        var overlapX:Number;
        var overlapY:Number;
        //check top-left corner
        if (platformMap[gameObject.top][gameObject.left] == platform)
        {
            overlapX = gameObject.xPos % maxTileSize;
            overlapY = gameObject.yPos % maxTileSize;
            if (overlapY >= overlapX)
            {
                if (gameObject.vy < 0 && platformMap[gameObject.bottom][gameObject.left] != platform)
                {
                    //Collision on top side of the object
                    gameObject.setY = gameObject.mapRow * maxTileSize;
                    gameObject.vy = 0;
                }
            }
            else
            {
                //Collision on left side of the object
                gameObject.setX = gameObject.mapColumn * maxTileSize;
                gameObject.vx = 0;
            }
        }
        //check top-right corner
        if (platformMap[gameObject.top][gameObject.right] == platform)
        {
            overlapX = maxTileSize - ((gameObject.xPos + gameObject.width) % maxTileSize);
            overlapY = gameObject.yPos % maxTileSize;
            if (overlapY >= overlapX)
            {
                if (gameObject.vy < 0 && platformMap[gameObject.bottom][gameObject.right] != platform)
                {
                    gameObject.setY = (gameObject.mapRow * maxTileSize);
                    gameObject.vy = 0;
                }
            }
            else
            {
                //Collision on right
                gameObject.setX = (gameObject.mapColumn * maxTileSize) + ((maxTileSize - gameObject.width) - 1);
                gameObject.vx = 0;
            }
        }
        //check bottom-left corner
        if (platformMap[gameObject.bottom][gameObject.left] == platform)
        {
            overlapX = gameObject.xPos % maxTileSize;
            overlapY = maxTileSize - ((gameObject.yPos + gameObject.height) % maxTileSize);
            if (overlapY >= overlapX)
            {
                if (gameObject.vy > 0 && platformMap[gameObject.top][gameObject.left] != platform)
                {
                    //trace("Collision on bottom");
                    //Collision on bottom
                    gameObject.setY = (gameObject.mapRow * maxTileSize) + (maxTileSize - gameObject.height);
                    gameObject.vy = 0;
                    gameObject.jumping = false;
                }
            }
            else
            {
                //trace("Collision on bottom left");
                //Collision on left
                gameObject.setX = gameObject.mapColumn * maxTileSize;
                gameObject.vx = 0;
            }
        }
        //check bottom-right corner
        if (platformMap[gameObject.bottom][gameObject.right] == platform)
        {
            overlapX = maxTileSize - ((gameObject.xPos + gameObject.width) % maxTileSize);
            overlapY = maxTileSize - ((gameObject.yPos + gameObject.height) % maxTileSize);
            if (overlapY >= overlapX)
            {
                if (gameObject.vy > 0 && platformMap[gameObject.top][gameObject.right] != platform)
                {
                    //trace("Collision on bottom right");
                    //Collision on bottom
                    gameObject.setY = (gameObject.mapRow * maxTileSize) + (maxTileSize - gameObject.height);
                    gameObject.vy = 0;
                    gameObject.jumping = false;
                }
            }
            else
            {
                //trace("Collision on right");
                //Collision on right
                gameObject.setX = (gameObject.mapColumn * maxTileSize) + ((maxTileSize - gameObject.width) - 1);
                gameObject.vx = 0;
            }
        }
    }

}

}
See example

    public function platformCollision(gameObject:TileModel, platformMap:Vector.<Vector.<int>>, maxTileSize:uint, platform:uint):void
    {
        var overlapX:Number;
        var overlapY:Number;
        if(gameObject.bottom < platformMap.length && gameObject.right < platformMap[0].length)
        {
        //check top-left corner
        //...

Example after updates

  • 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-17T13:03:04+00:00Added an answer on June 17, 2026 at 1:03 pm

    There is nothing wrong with the code you posted, but neither of those have an object at index 10? Maybe you should be looking at index 9 as it starts at 0?

    Could you show how you are accessing the array/vector? I think that is where the error is coming from.

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

Sidebar

Related Questions

I need a function that can return the difference between the below two dates
I have two array list. Each has list of Objects of type User. The
I had a function below which stores distances from two locations using google maps
Suppose I want to define an enum pointing to an array of objects. Can
I need to create a large two dimensional array of objects. I've read some
I'm trying to build a javascript array of objects, parsing dates using date.js, and
I have two array list. Each has list of Objects of type Employee. The
How do I add objects to a two-dimensional array? The array is initiated with
I have two array list. Each has list of Objects of type Employee. The
In the Code Below there are Two Classes. One Object of type two is

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.