Store object in a panel's value object with undefined sub objects...
-
@Christoph-Hart Yeah so this was driving me nuts for hours. And now I've found what it was I reckon it happened to me already in the past...
SoI have an object that is containing some undefined values, like:
reg myArray = [{obj:"blabla", area:undefined}];
You can apparently store it successfully in a panel value as I see it in the xml afterward. But at recall time, the object won't load because its type will be
number
instead ofobject
(failing the check of 1st initialisation)reg myArray = [{obj:"blabla", area:undefined}]; inline function onPanelControl(component, value) { if (typeof(value) != "object") component.setValue(myArray); else Console.print(trace(component.getValue())); // never arrives here... }; Panel.setControlCallback(onPanelControl);
So the issue is that
undefined
isn't parsed and of course I can fix that with whatever value,[]
or""
instead.<Control type="ScriptPanel" id="mbPnl" value="JSON[{"obj": "blabla", "area": undefined, ... // Not parsed
undefined
is very useful when scripting, so it it possible to make it parsable? -
@Christoph-Hart Actually it's even worse...
area
later becomes aRectangle
object, that of course won't recall... I have to let go the Rectangle option for the project and stick with the ol' array... -
@ustk you can always convert back and to an rectangle from an array, but yeah for storing / restoring things you need to resort to vanilla Javascript data types.
-
@Christoph-Hart Yeah in the end it wasn't hard to just jump between Rectangles and arrays
area = Rectangle(fromArray).modify().toArray();