After I started making more complex lenses that have multiple UI elements that need to be displayed and then removed from the screen I noticed that the enabled (true/false) way of doing it is very annoying.
For example, when I have a UI Toggle (from the user interface extra bundle provided by Snap) and I want to remove it from the screen I would do enabled=false either on itself or on it's parent scene. The problem is once I set enabled=true again now none of the api methods of the UI Toggle are recognized. It's like if it doesn't understand anymore that it's a UI Toggle.
This is how I get a reference to the UIToggle element via script:
then I set
and now the UIToggle is broken:
18:44:55 [Scenarium] TypeError: undefined not callable (property 'toggleOff' of [object Object])
at loadAnswers (Create/CreateController.js:68)
at loadQuestion (Create/CreateController.js:40)
at [anon] (Create/CreateController.js:14) preventsyield
What I am going to do to hide the Toggle then is move it outside of the view bounds which is a terrible solution but gets the job done. Then when I want to display it again on the screen I just set its position back to the original one.
The same thing holds true for SceneObjects. It would be great if a scene object could have at least an alpha property so it could be not displayed instead of setting enabled=false which makes it lose all of its knowledge of methods once it's re-enabled again.
In iOS I would say the equivalent of the SceneObject is a UIView which has an alpha property just like any of its subclasses. Everything basically inherits from it. It's odd that an image object on Lens Studio would have an alpha property but a SceneObject wouldn't.