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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T03:21:52+00:00 2026-05-19T03:21:52+00:00

As I’ve found recently, setting width / height properties on a Sprite only forces

  • 0

As I’ve found recently, setting width/height properties on a Sprite only forces the Sprite to fit the given dimensions by scaling the actual size, which is calculated by Flash based on the rendered content.

This leaves me confused. If I have a custom Sprite subclass which draws using Graphics, how can I do layout before an initial render – the size will be zero until it is first drawn?

For a more complex issue, let’s say I have a 2D game world with objects spread over a wide area with world coordinates from (0,0) to (5000,5000), where each object has a size of maybe up to 100×100.
I want to have a Flash component which is the “game window”, and has a fixed size like 400×300, rendering part of the game world. So how do I force the game window size to 400×300 pixels? I can draw a 400×300 rectangle to get the size correct but then if I draw any objects which are partly in-view, they can screw this up.

Is the right approach to provide a custom setSize(w,h) method which is used rather than width & height setters? But even so, is there no way to make a Sprite force to the size I want? Do you really have to catch it every render and re-scale it?

  • 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-05-19T03:21:53+00:00Added an answer on May 19, 2026 at 3:21 am

    If I understand correctly, your game world is a child object of your window, and its size is always 5000×5000, but you need width and height of the window to refer only to the window itself? Use a mask, as the other comment suggests, then override the width and height getters and setters:

    private var _width: Number = 400;
    private var _height : Number = 300;
    private var _mask : Sprite;
    
    // some code in between
    
    override public function get width () : Number {
        return _width;
    }
    
    override public function get height () : Number {
        return _height;
    }
    
    override public function set width ( wid:Number ) : void {
        _width = wid;
        if(_mask != null) _mask.width = wid;
    }
    
    override public function set height ( hei : Number ) : void {
        _height = hei;
        if (_mask != null) _mask.height = hei;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a French site that I want to parse, but am running into

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.