Reputation: 2859
I'm removing an UIComponent
but parts of it last being visible.
It redraws only when I move mouse around or something. I tried to do validateNow()
on its parent, tried to do setTimeout(validateNow, 100)
but it doesn't help. When I call it by setTimeout
it seems these artifacts shown more rarely but it doesn't solve a problem in all cases. Please guide me someone to read about validateNow()
, how it works and how to make these things correctly.
The code is below:
protected var bubble: SpeechBubble;
// creation
bubble = new SpeechBubble();
map.addChild(bubble);
//...
// removing
bubble.visible = false;
map.removeChild(bubble);
map.validateNow();
setTimeout(map.validateNow, 100);
map is Google Map for Flex.
Upvotes: 0
Views: 4231
Reputation: 12847
The reason this is happening is because you're messing with the Google Maps drawing logic. You should look at the developer guide provided by google. It mentions in the controls section that to create a custom control, you need to extend ControlBase
.
Upvotes: 2
Reputation: 19748
You may need to trigger invalidation before calling validateNow(). The call to validate now causes the code to check if any of the invalidation flags are set (properties, display list, or size) then for each calls the appropriate method to correct the invalidation (commitProperties, updateDisplayList, measure) in your case it sounds like it's just not doing the clear call to the graphics or redrawing appropriately so you may need to call
bubble.invalidateDisplayList();
bubble.validateNow();
Also hope one of these solutions works out for you, generally speaking forcing validation at a given time is not usually a good idea as the framework components should trigger the appropriate invalidation and subsequent validation in it's life cycle, but I can't say I haven't done this myself :).
Shaun
Upvotes: 1
Reputation: 3024
You may use includeInLayout property
bubble.visible = false;
bubble.includeInLayout = false;
Example demonstrates this property
hopes that helps
Upvotes: -2