Warning: 3D DisplayObject will not render. Its dimensions (6711131, 6711131) are too large to be drawn

StackOverflow https://stackoverflow.com/questions/5326401

Question

I'm very very new on ActionScript 3.0 for BlackBerry Playbook.

I'm trying to resize an image loaded with Loader class. But, when I set up its new size with this function:

private function loaded(event:Event):void
{
    var targetLoader:Loader = Loader(event.target.loader);
    targetLoader.height = 240;
    targetLoader.width = 240;
}

I get the following error:

Warning: 3D DisplayObject will not render. Its dimensions (6711131, 6711131) are too large to be drawn.

I'm using two images: one has 152.292 bytes, the other has 170.663 bytes

Was it helpful?

Solution

That's because the z property of your object is not 0 (so is in 3D) or it has a child in 3D that is it to big to draw. When you resize an object in flash 3D for example 2x the result may not be 2x (think in a plane) flash draws objects in 2D and the rectangle is to big to be drawn.

When the objects are rotated you enlarge this result:

enter image description here

In this example the difference is 31 pixels, but in larger images the difference would be enormous, like in your case of 6711131 pixels

OTHER TIPS

The error message says 3D DisplayObject, might it be that you have some sort of scaling / perspective in 3D which would blow your image up to that amazing looking 6.7 million pixels dimension? :)

The message suggests (as other responders have said) that you are applying some 3D transformation to the Loader or some of its ascendants in the display tree.

However, the cause of the unexpected huge size is probably another one.

This typically happens when attempting to set the width or height property to a display object when it is still empty (i.e. before a Loader has finished loading). If you do so (i.e. someobject.width=240 when the object is still empty), you apply to it an infinite scaling; then later, as soon as the object actually is filled with something (i.e. the loader finishes loading), you end up with a huge object.

In your case it seems you are setting dimension when the Loader has finished loading (so it shouldn't happen); however I remember experiencing Flash runtime bugs where the object's width/height property wasn't updated when it should, leading to exactly this issue, though I'm not 100% sure it is your case.

If this is the case, a workaround is to directly set the scaleX and scaleY properties rather than the width and height properties. If you know in advance the expected dimensions of the loaded image you can write:

private function loaded(event:Event):void
{
  var targetLoader:Loader = Loader(event.target.loader);
  targetLoader.scaleY = targetLoader.scaleX = 240/EXPECTED_WIDTH_HERE;
}

otherwise you can use the width and height properties OF THE LOADERINFO OBJECT instead of those of the Loader object. These tell you the "nominal" size of the loaded image:

private function loaded(event:Event):void
{
  var targetLoader:Loader = Loader(event.target.loader);
  targetLoader.scaleY = targetLoader.scaleX = 240/targetloader.contentLoaderInfo.width;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top