I’ve got a sprite which I want to temporarily hide… But changing the .visible property doesn’t do what I expect. The code looks roughly like this:
childLayer.visible = false;
onLoadComplete(function():void {
childLayer.visible = true;
});
But the childLayer isn’t being hidden right away (in fact, it doesn’t appear to be hidden at all unless I remove the childLayer.visible = true, in which case it does eventually hide).
However, if I remove the childLayer from the parent, everything works just like I would expect:
parentLayer.removeChild(childLayer);
onLoadComplete(function():void {
parentLayer.addChild(childLayer);
});
Why would removing the child work when setting .visible = false “not work”?
Edit: turns out I’m just an idiot. Some other component was setting childLayer.visible = true before the onLoadComplete callback was called.
Hey David, hard to say without seeing more code. One thing I know can cause issues is using cacheAsBitmap, is that set anywhere on the display list above this object? If set, it might not be refreshing correctly. It should work immediately (next render loop).
What does onLoadComplete look like?