var mcScrollView - is empty Sprite from GUI constructor (see on picture)
var visibleRect = new Rectangle(0, 0, 530, 350);
var mcContainer = new Sprite();
mcScrollView.addChild(mcContainer);
var quad:Quad = new Quad(visibleRect.width, visibleRect.height);
quad.x = visibleRect.x;
quad.y = visibleRect.y;
mcScrollView.mask = quad;
mcContainer.addChild(new FaqSlot());
mcContainer.addChild(new FaqSlot());
mcContainer.addChild(new FaqSlot());
...
code to implement scrolling content (I change _mcContainer.y)
...
All works as expected for openfl build html5 -debug:
But for openfl build html5 -final --no-traces I see strange position and size of masking:
Like visibleRect = new Rectangle(0, -30, 400, 280);
There’s probably some kind of reflection being used. Either in your project’s code or in Starling’s code. Reflection often doesn’t work well with -final, since -final enables more aggressive dead code elimination (dce).
I remember that I had to put in a decent amount of work to get Feathers UI working with -final because Actuate.tween() isn’t compatible with -final, and I had to switch to Actuate.update() instead, to force my code to be more strongly typed. There’s probably a similar issue with Starling’s Tween class, since it uses reflection, but that may not necessarily be the cause of the issue at hand. I only mention this because the mask appears to be used for scrolling, and scrolling is often animated.
I have the same problem. I need tween class field (set property).
With -debug all right. There are many updates per second and finally property turn into right value.
With -final there are only one or two updates and property turn into custom value. It is strange. I add onComplete() to manually set property at the end of tween.
Actuate.update() use tween() inside. So what difference for this case?
What can you recommend? I think I need -final for production version.
Actuate.update() accepts a function, rather than an anonymous structure, so the compiler is aware of exactly which properties are being animated, and they won’t be removed by dce.
if you can, please explain how it helps ? You mean using it or looking at the code ? I’m quite busy currently but I’d like to help make Starling as “perfect” as possible.
Also, have you tried reproducing your mask issue outside of your game ?
About Actuate.tween
Actuate is not part of Starling. So there are no complaints to Starling)
I have
public var count(get, set):Int;
function set_count(value:Int):Int
{}
function get_count():Int
{}
I replace Actuate.tween(this, _duration, {count: newValue});
to Actuate.update(set_count, _duration, [count], [newValue]);
About mask
Only now I noticed, that problem present on remote server. And no problem with local Visual Studio “Live Server”. And -final -release -debug flags do not affect on this!
Browser is the same. It is magic!)
Thx! But .js file size has doubled) I think size difference is because of I don’t use all of lime|OpenFL|Starling classes in my project. Not only DCE. So I prefer -final for now. But I will keep in mind -release -minify
I mean, it’s totally fine to use -final. Ideally, you should want to use -final, but I understand when some developers prefer not to put in the extra effort that is sometimes required. The main thing to remember with -final is that you must ensure that you aren’t using reflection on Haxe classes (either explicitly with the Reflect class, or sometimes implicitly with the Dynamic type).