Some trouble with swf in layout

Got some questions about this:

  • While using a swf bigger than 12MB I get a warning and it stops loading. It is hitting on the project.xml declaration of the the file. Either I chose to preload or not.

  • If the file is under 12MB and preload is false I don’t get the symbols available so I can’t manipulate the playhead on the swf. So I’m guessing I’m missing some load instruction inside the .hx maybe to load it on cue before manipulation… maybe some .onComplete.

  • With a big file , in Flash, you can still get:
    [Fault] exception, information=TypeError: Error #1009: Cannot access a property or method of a null object reference.
    on the immediate
    layout.resize (stage.stageWidth, stage.stageHeight);
    after doing:
    layout.addItem (new LayoutItem (clip.getChildByName (“ornamentos_class”), CENTER, CENTER, false, false));
    Reflect.hx comes up. Maybe this is happening because the file isn’t available yet. Is this async ?

  • Even with Preload set to true it doesn’t allow a normal first play of the .swf on the windows target. Flash target works ok. But windows just does a botched strobe jumpy first play. Playing after that appears to work ok both flash and windows.

  • Controlling play of the .swf. If I wanna play it just once and stop do I have to rely on some onenterframe event to check for a label or a specific frame number going by ?
    .currentFrame or .currentFrameLabel I am guessing…

  • Also layout.resize isn’t doing an actual resize at least on my machine. In Windows it interacts in a weird way with high dpi zoom percentage adjusted setups. Windows target doesn’t really resize anything when the size of the window changes. Though it doesn’t throw any error like flash is doing. Sysinternals Process Explorer tells me the binary isn’t dpi aware, though it is showing leftwards and top align when suppose to be centered when DPI zoom is set. Maybe I’m also having problems because of the 4K monitor on some edge case…

  • layout.resize in flash, both ctrl+f or window maximize or drag, is throwing:
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at Reflect$/hasField()[C:\HaxeToolkit\haxe\std\flash_std\Reflect.hx:25]
    at layout::LayoutGroup/refreshSize()[C:\HaxeToolkit\haxe\lib\layout\1,2,1\layout\LayoutGroup.hx:313]
    at layout::Layout/resize()[C:\HaxeToolkit\haxe\lib\layout\1,2,1\layout\Layout.hx:73]
    at Main/stage_onResize()[D:\WORK\HXPROJECTS\SimpleSWFLayout\Source\Main.hx:57]

This doesn’t happen when using the SimpleSWFLayout example .swf. Probably connected to the first issue, maybe. Again Reflect.hx comes up, line:25. return o.hasOwnProperty( field );

The used mem sky rockets for this code in the windows target, close to 2 GB with just one .swf. Maybe that could be a problem going further, probably should be using the flash target for this.
Any thoughts appreciated.
Thanks :slight_smile:

EDIT: HTML5 resizes like a champ.

There’s some information here about async loading of .swf assets where preload=false

For controlling playback: You’ll need a listener to watch the currentFrame or currentFrameLabel. It’s a little tricky, because some frames can be dropped if performance dips or if the OpenFL framerate differs from the swf framerate. You can’t always rely on catching it when currentFrame == timeline length. I found it simplest to store the lastKnownFrame and pause playback if the currentFrame is ever less than that (when it loops back to the start).

1 Like

Thanks for the valuable tips david_is_neato.

I have seen errors when including SWF files that are larger than 12MB, at least on the Flash target. Something to do with the Haxe compiler?

If preload="false you can Assets.loadLibrary to load it later

After you instantiate a symbol, you may be able to clip.addFrameScript to add a stop() action to the last frame (but beware, addFrameScript uses a zero-index)

1 Like

Thanks for the info on these.
I found tthe 12MB thing in an ocaml file on the haxe git.