Why is the width and height of the loaded SWFLoader equal to zero?

I have a class that extends SWFLoader, I use it as a regular SWFLoader:

var loader:MySWFLoader = new MySWFLoader();
loader.load("myFile.SWF");
myScene.addChild(loader);

The load is fine, except that it remains 0 because the width and height never change from 0. I had to redefine the width / height get properties to make it work:

class MySWFLoader extends SWFLoader
{
public override function get width():Number{    return contentWidth;    }
public override function get height():Number{   return contentHeight;   }
}

Like a big hack, this is not entirely correct; especially since SWF has several frames, and frames have different widths / heights.

Why doesn't width / height work in the first place? Shouldn't they automatically install at boot time? Is it possible that the problem is related to the SWF itself?

Update : changing the scaleContent value to true or false does not matter.

+3
source share
4

, SWF, , , , .

, , , , /.

loaderInfo AS3

+2

, ( - ), , SWFLoader.loaderInfo.height SWFLoader.loaderInfo.width.

+1

SWFLoader , . , , scaleContent false.

0

SWFLoader UIComponent.

It needs to be run through the UIComponent structure in order to correctly set its dimensions.

In other words, it is waiting for calls to commitProperties (), updateDisplayList (), etc.

If you drop it in your application (so that it is part of the framework), this should be fine.

0
source

Source: https://habr.com/ru/post/1698338/


All Articles