开发者

Item Renderer having trouble updating

开发者 https://www.devze.com 2023-01-02 17:59 出处:网络
I have a list ItemRenderer that has 2 states. When it initializes, I set it to 1 state and listen for an event that switches it to state 2.

I have a list ItemRenderer that has 2 states. When it initializes, I set it to 1 state and listen for an event that switches it to state 2.

protected function onCreationComplete(event:FlexEvent):void{
   currentState = "state1";
   addEventListener(CustomEvent.Event1, switcherfunc);
}

protected function switcherfunc(event:FlexEvent):void{
   currentState = "state2";
}

The difference between the 2 states is that I hide/show some labels.

The problem is that it doesn't work. I still see the visual of the old state, even though if I Alert.show(currentState), it shows the correct state name.

I've tried adding the line invalidateDisplayList(); inside the sw开发者_如何学编程itch function but still no luck.

protected function switch(event:FlexEvent):void{
   currentState = "state2";
   invalidateDisplayList();
}

What am I doing wrong. Any ideas how I can get this ItemRenderer to really update?

0

精彩评论

暂无评论...
验证码 换一张
取 消