• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1019
  • Last Modified:

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

Hello,

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. :)
PrintStuffDS.as
Product.as
T-color.png
T-overlay.png
0
chaseivey
Asked:
chaseivey
1 Solution
 
leakim971PluritechnicianCommented:
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
0
 
chaseiveyAuthor Commented:
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 :)
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now