Hey ppl!
I'm trying to buil a menu component in here and I ran in some strange
issues.
I know how to workaround this issue but still i'm pretty much interested in
why is it so.
What I have is pretty straight forward routine. When user sets dataProvider
I set allChildrenChanged = true and fire invalidateDisplayList() so
updateDisplayList() gets called on next frame render.
Afterwards in updateDisplayList I have this:
override protected function updateDisplayList(unscaledWidth:Number,
unscaledHeight:Number):void {
super.updateDisplayList(unscaledWidth, unscaledHeight);
if(allChildrenChanged == true){
allChildrenChanged = false;
removeChildren();
_dataProvider.source.forEach(createChild);
}
}
And protected method that handles single menu subitem creation:
protected function createChild(element:Object, index:int, arr:Array):void {
var child:MenuItem = new MenuItem();
child.addEventListener(MacMenuItemEvent.ROLL_OVER, onRollOverChild);
child.addEventListener(MacMenuItemEvent.ROLL_OUT, onRollOutChild);
child.itemId = element.id
child.icon = element.icon
trace("child "+child)
addChild(child);
}
At this point, _dataProvider has several records of proper type, createChild
is called proper number of times trace("child "+child) trace exactly what
I've been expecting.
But, theres and error "ArgumentError: Error #2004: One of the parameters is
invalid.".
Wheres a problem? MenuItem class extends mx.controlls.Image and work just
fine when used without this class.
The most amazing thing is that if I move exactly the same code from
updateDisplayList to commitProperties it just works.
regards
janis radins