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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:30:07+00:00 2026-06-09T16:30:07+00:00

I have a ‘InvZone’ class in flash that extends sprite. The idea is that

  • 0

I have a ‘InvZone’ class in flash that extends sprite. The idea is that this class will create an array of Sprite children, compute and assign x,y,width and height properties to them and then addChild them in rows (how many rows and children being specified in the arguments).

Both the sprite (invZone) and its children (invWindow) are in the Flash library. There they have symbols added to provide backgrounds and make sure their initial starting dimension are not 0.

My problem is – the act of adding the children seems to be throwing out the height and width values of the InvZone instance. I would expect that if the children (in row and column totals) somehow exceeded the initial dimensions of the InvZone, but my code should be preventing that (unless I am totes codeblind on some issue).

Here is the class code:

package pnc.gui {

import flash.display.Sprite;
import pnc.gui.InvWindow;

public class InvZone extends Sprite {

    public const PADDING_X:int = 5
    public const PADDING_Y:int = 5  
    public var invWindowArray = new Array();
    public var invArray = new Array();
    private var windows:int;
    private var rows:int;

    public function InvZone(inputX:int, inputY:int, inputHeight:int, inputWidth:int, inputWindows:int, inputRows:int) {
        //normally these would set by args, but today we'll set them by hand
        height = 100;
        width = 600;
        x=0;
        y=0;
        windows = 16
        rows = 3

        init()  
    }

    private function init() {
        var windowsPerRow:int = Math.ceil(windows/rows);
        var rowHeight:Number = (height - (2*PADDING_Y))/rows;
        var columnFullWidth:Number = (width - (2*PADDING_X))/windowsPerRow


        for (var i = 0; i<windows; i++) {
            var currentRow:int = Math.floor(i/windowsPerRow)
            var invWindow:InvWindow = new InvWindow();
            invWindowArray.push(invWindow);

            invWindowArray[i].x = (columnFullWidth * (i%windowsPerRow)) + PADDING_X;
            //trace("X:"+invWindowArray[i].x)

            invWindowArray[i].y = (rowHeight * currentRow) + PADDING_Y;
            //trace("Y:"+invWindowArray[i].y)

            invWindowArray[i].height = rowHeight - PADDING_Y;
            //trace("HEIGHT:"+invWindowArray[i].height)

            invWindowArray[i].width = columnFullWidth - PADDING_X;
            //trace("WIDTH:"+invWindowArray[i].width)

            trace(" ContainingSpriteHeight: " + height + " rowHeight: " + rowHeight + " currentRow: " + currentRow);
            if (invWindowArray[i]) {
                addChild(invWindowArray[i]);
            }
        }
    }       
}   
}

And here is the trace:

 ContainingSpriteHeight: 100 rowHeight: 30 currentRow: 0
 ContainingSpriteHeight: 100 rowHeight: 30 currentRow: 0
 ContainingSpriteHeight: 100 rowHeight: 30 currentRow: 0
 ContainingSpriteHeight: 100 rowHeight: 30 currentRow: 0
 ContainingSpriteHeight: 100 rowHeight: 30 currentRow: 0
 ContainingSpriteHeight: 100 rowHeight: 30 currentRow: 0
 ContainingSpriteHeight: 100 rowHeight: 30 currentRow: 1
 ContainingSpriteHeight: 100 rowHeight: 30 currentRow: 1
 ContainingSpriteHeight: 100 rowHeight: 30 currentRow: 1
 ContainingSpriteHeight: 100 rowHeight: 30 currentRow: 1
 ContainingSpriteHeight: 100 rowHeight: 30 currentRow: 1
 ContainingSpriteHeight: 100 rowHeight: 30 currentRow: 1
 ContainingSpriteHeight: 100 rowHeight: 30 currentRow: 2
 ContainingSpriteHeight: 128.55 rowHeight: 30 currentRow: 2
 ContainingSpriteHeight: 128.55 rowHeight: 30 currentRow: 2
 ContainingSpriteHeight: 128.55 rowHeight: 30 currentRow: 2

So the last row is somehow pushing against the containing sprite – but I am at a loss as to how this happens. Height is not the only value affected – the containing width can be blown out with different variables. When this occurs, all the InvWindow sprites change size consistently but not the original background symbol from the library. Ive tried shifting declarations and adding ADDED_TO_STAGE listeners, but there is no change. Can someone hit me with a clue stick, please?

UPDATE: To clarify: I don’t think the children’s edges should exceed the boundaries of the containing sprite – and so AFAIK it shouldn’t expand at all. Sanchez has fixed the symptom, but what’s the cause of the containing InvZone expanding and stretching the InvWindows?

UPDATE2 with solution: Acting on Sanchez’s suggestion below to look to see what might be scaling – I realised the background sprite added to invZone in the library to give it a dimension was scaling in unexpected ways, breaking the boundaries. By adding the background sprite in code rather than in the library, giving it the arguments for the class for h & w and letting it define invZone’s dimensions, the problem went away.

  • 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-09T16:30:09+00:00Added an answer on June 9, 2026 at 4:30 pm

    If I understand, you want your InvZone to return height and width set by you rather then beining calculated based on the content?

    In this case you could override the getters for width and height to return your values.

    Replace:

    height = 100;
    width = 600;
    

    with:

    _h = 100;
    _w = 600;
    

    And add:

    private var _w;
    private var _h;
    
    
    override public function get height():Number 
    {
       return _h;
    }
    
    override public function set height(value:Number):void 
    {
       super.height = value;
    }
    
    override public function get width():Number 
    {
       return _w;
    }
    
    override public function set width(value:Number):void 
    {
       super.width = value;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have data that has this kind of structure. Will be in ascending order by
have written this little class, which generates a UUID every time an object of
Have data that has this kind of structure: $input = [ { animal: 'cat',
Have some dates in my local Oracle 11g database that are in this format:
have a problem. At first look at this HTML <div id=map style=background-image: url(map.png); width:
have a nice day. I got problem when trying to create an image from
**Have it working now. I forgot to populate the Array List. How embarrassing. I'm
Have converted devise new session from erb to Haml but doens't work, this is
have anyone can tell me what syntax error on this actionscript (actionscript3.0)? var rotY:
Have a bunch of WCF REST services hosted on Azure that access a SQL

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.