Skip to main content
Participating Frequently
April 20, 2009
Question

Flash not setting width of DisplayObjects?

  • April 20, 2009
  • 1 reply
  • 576 views

Hi all you flash gurus,

I've got another interesting Flash issue, and I was wondering if there was some weird case I had to account for.  Here's the code:

var c:DisplayObject;
var t:Rectangle;


c.
width = t.width;
trace(c.width, t.width);

This results in output of:

0 13

I'm expecting '13 13' as the output...  Any ideas what would cause this to happen?  It's sporadic, sometimes it'll happen, sometimes it doesn't.  Is there some weird race condition I should double check for?

Thanks!

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
April 20, 2009

are c and t instantiated somewhere?

Participating Frequently
April 20, 2009

Oh, whoops, I forgot to set those in the example.  I was reformatting a function for this purpose, here's the function:

        protected function setTo(c:DisplayObject, t:Rectangle):void
        {
            c.width = t.width;
            trace(c.width, t.width);

kglad
Community Expert
Community Expert
April 20, 2009

that still fails to show a display object and rectangle being instantiated.   there are a number of ways you can instantiate each of those instances so i'm not sure what you're doing.