The code shows an “as IVisualElement”. If the elements is not an IVisualElement then element will be assigned null.
Yes, at first I thought it was a failed casting operation. But upon further examination that wasn't the case. For instance, the "thing" object in the following code is null, even though the layoutTarget.numElements = 1.
for( var i:int = 0; i < layoutTarget.numElements; i++ )
var thing:Object = layoutTarget.getElementAt(i);
//the "thing" is null
For background information, I am using the layout code from the Flex 4 Cookbook by O'Reilly found on page 96.
Any help is greatly appreciated.
I think it had something to do with my Layout class extending LayoutBase. Once I changed the superclass to VerticalLayout, it behaved. It still throws errors, but that is for another day.