Hi,
I need to know the best way to deal with styles updates and component
resizing in a custom component. I will try to be more precise.
I'm making a light volume controller component. To customize it, i
have added some custom styles like progressBarBackgroundColor.
As decribed in flex doc, i have used flags to limit the redraw to
updated items and this is the result.
private bProgressBarStylesChanged = true;
override public function styleChanged(styleProp:String):void
{
super.styleChanged(styleProp);
var allStyles:Boolean = styleProp == null ||
styleProp == "styleName";
// Check to see if progressBar styles changed.
if ( allStyles || styleProp=="progressBarBackgroundColor" )
{
bProgressBarStylesChanged = true;
invalidateDisplayList();
return;
}
}
override protected function updateDisplayList(...):void
{
super.updateDisplayList(unscaledWidth, unscaledHeight);
if ( bProgressBarStylesChanged )
{
//redraw progressbar
...
bProgressBarStylesChanged = false;
}
}
This works fine for when a style changed but obviously not yet when i
resize my component (the value of the bProgressBarStylesChanged
preventing the redraw of the item). So i decided to catch the resize
event and set a specific flag bDimensionChanged to describe the state.
This the new version.
// constructor
public function MediaVolumeController()
{
super();
addEventListener( ResizeEvent.RESIZE, handleResizing );
}
private function handleResizing( event:ResizeEvent ):void
{
bDimensionChanged = true;
}
override protected function updateDisplayList(...):void
{
super.updateDisplayList(unscaledWidth, unscaledHeight);
if ( bDimensionChanged || bProgressBarStylesChanged )
{
//redraw progressbar
...
bProgressBarStylesChanged = false;
}
bDimensionChanged = false;
}
Everything works fine now, but it seems that it's not the way that mx
component have been done. What the best way to do that?
Thanks for your help.
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/flexcoders/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/