Why does my Sprite always have a width and height of ZERO?

Posted on 2012-08-15
Last Modified: 2012-08-16

I have created a class that extends Sprite.  This class loads external display assets (2 images) into itself and is then used to display these assets on the screen.  My display works fine, but when I try to programatically address the width and height of the object, the values are always zero.  ?
I can resize the object by using scaleX & scaleY, but I have no control over the width or height variables, as they are always mysteriously zero.

I have attached my code, along with the refernced display assets.  The main class is PrintStuffDS and the class in question is Product.

I have included trace statements to show the problem.

Please advise. :)
Question by:chaseivey
    LVL 81

    Accepted Solution

    The images are loaded asynchronously else loading an image will stop execution of your program (for example a 10M image)
    So until Event.COMPLETE fired, you CAN'T retrieve width and height

    You need to update your classes or change your logic

    Author Closing Comment

    Thank you!
    I updated my main class to listen for the complete event before adding the sprite to the stage.  Now all is working fine :)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
    Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
    The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now