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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:29:59+00:00 2026-06-04T04:29:59+00:00

I am working on flex application and part of the application is the grid.

  • 0

I am working on flex application and part of the application is the grid. App is supposed to be game editor later on.

My problem is illustrated by the following screenshot:
I wanted to place image here but it seems I don’t have enough reputation.
here is link to screenshot
Orange-like square and red triangle does not matter.

This code below is Sprite (DisplayObjectContainer) for red squares. Code is messy because I’m getting started with flex and wanted to get that grid done really quick.

public class Board extends Sprite
{
    var board:Array;

    public function Board(blockLength:Number)
    {
        super();
        x = 0;
        y = 0;
        // Setting up two dim array
        board = new Array(10);
        for (var k:int = 0; k < board.length; k++) 
        {
            board[k] = new Array(10);
        }

        // Orange-like box
        graphics.lineStyle(1, 0xA3A3A3);
        graphics.beginFill(0xCCAA00); 
        graphics.drawRect(x,y,100, 100);
        graphics.endFill(); 

        // red blocks
        for (var i:int = 0; i < 10; ++i) 
        { 
            for(var j:int = 0; j < 10; ++j)
            {
                var block:Block = new Block(i*blockLength, j*blockLength);  
                board[i][j] = block;
                this.addChild(block);
                block.drawBlock(blockLength);                   
            }
        }           
    }
}

Red square is defined as follows:

public class Block extends Shape
{

    public function Block(x:Number, y:Number)
    {
        super();
        this.x = x;
        this.y = y;
    }

    public function drawBlock(length:Number)
    {
        graphics.lineStyle(1, 0xB3B3B3);
        graphics.beginFill(0xFF0000); 
        graphics.drawRect(x,y,length, length);
        graphics.endFill();
    }
}

I really have no idea why there are gaps. There is very little code and I feel like I’am missing something very obvious. Board object is added to stage after its initialized.

Why there are gaps between red blocks?

  • 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-04T04:30:00+00:00Added an answer on June 4, 2026 at 4:30 am

    Answer as you may suspect is simple – you are making these gaps 🙂 .

    Try to change that:

    graphics.drawRect(x,y,length, length);
    

    To that:

    graphics.drawRect(0,0,length, length);
    

    Why?

    At first you set a position of registration point of the square:

        this.x = x;
        this.y = y;
    

    But then you set a position of rect in relation to that registration point:

    graphics.drawRect(x,y,length, length);
    

    That made the gap.

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

Sidebar

Related Questions

I have a working Flex/BlazeDS application (for simple AMF remoting) with the following settings:
I am working on a Flex application/game where a lot of UIComponents are moved
Currently I am working on flex application where I am using multicore variant of
I'm working with flex, but actionscript ideas are just as good. The flex <s:Application>
I'm warming up w/ AS3 robotlegs framework. I'm working on a FLEX 4/AIR Application
I'm working on a Java web application (Adobe Flex front-end, JPA/Hibernate/BlazeDS/Spring MVC backend) and
i am working in application of twitter in flex 3 and action script 3
I've recently started working with an application written using Adobe Flex 3. We're using
I am working on a modularized Flex application, and I am trying to cut-down
I am working in on a Flex / Air application (using PureMVC) written virtually

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.