Probably a dumb question, but if i start doing that doesn't that take alot more
code to accomplish simple things. For example, i am rewriting the
SuperTabNavigator Class for practice and trying to implement many of these
methods but so far my code is twice the length as the regular SuperTabNavigator
and doesn';t that in return consume more memory.
/**
* Used to Determine whether or not there was a change in the Close Policy
*/
private var _closePolicyChanged:Boolean;
/**
* Internal Value for the ClosePolicy so we can react
* accordingly
*/
private var _closePolicy:String;
[Inspectable(defaultValue="close_always",enumeration="close_always,close_rollover,close_never,close_selected")]
public function set closePolicy(value:String):void{
if(_closePolicy !=value){
_closePolicy=value;
_closePolicyChanged=true;
invalidateProperties();
dispatchEvent(new Event("closePolicyChanged"));
}
}
[Bindable(event="closePolicyChanged")]
public function get closePolicy():String{
return _closePolicy;
}
/**
* Override the CreateChildren so we can create the Close Button, Only Create
Children
* and nothing else, can't size them or position them
*/
override protected function createChildren():void{
//call the super method so the other stuff gets constructed like
//the Button itself and all the other stuff that creates the Tab
super.createChildren();
//always check if the Button is not made
if(!closeButton){
//safe now we can create it
closeButton = new Button();
//listen for the click event so we know when to close the tab
closeButton.addEventListener(MouseEvent.CLICK,onCloseButtonClickHandler);
//hide the close button
closeButton.visible=false;
_closeButtonCreated = true;
addChild(closeButton);
}
/**
* Used to Display the Indicator, first get the Style as a class
* then what you would need to do is create the style as a class
*/
if(!indicatorDisplay){
indicatorDisplay = new UIComponent()
addChild(indicatorDisplay as DisplayObject);
}
//call to set the styles
setCustomStyles();
}
/**
* Override the measure to set the compenents custom size
* We set the Close Button Size here and the Indicator??
*/
override protected function measure():void{
super.measure();
if(_closeButtonCreated){
closeButton.width = closeButton.height=16;
_closeButtonCreated=false;
}
}
----- Original Message ----
From: rueter007 <[EMAIL PROTECTED]>
To: [email protected]
Sent: Wednesday, February 6, 2008 6:40:05 PM
Subject: [flexcoders] Re: is this how to use commitProperties
updateDisplayList is called in the next render event. So, I would
assume updateDisplayList will be called once for each render no matter
how many times you call the invalidateDispayLis t in that cycle. Going
through commitProperties will ensure that you do not repeat any
complex calculations on the setter every time a value changes but
instead do it once in the commitProperties. You can add the button in
the createChildren( ) method but do any calculations on the sizes in
the measure.
As the documentation says:
"Calls to the commitProperties( ) method occur before calls to the
measure() method. This lets you set property values that the measure()
method might use."
--- In [EMAIL PROTECTED] ups.com, Sherif Abdou <[EMAIL PROTECTED] ..> wrote:
>
> and would something like this call the invalidateDisplayLi st() 3
times or just once. I am not doing anything special just trying to
figure out best practices.
> /**
> * Create the CommitProperties so we determine if there is a need
> * to change the closePolicy Buttons
> */
> override protected function commitProperties( ):void{
> super.commitPropert ies();
> if(_closePolicyChan ged){
> closeButton. visible=true;
> invalidateDisplayLi st();
> _closePolicyChanged =false;
> }
> if(_buttonDisplayCh ange){
> invalidateDisplayLi st();
> }
> if(true){
> invalidateDisplayLi st();
> }
> }
>
>
>
> ----- Original Message ----
> From: Sherif Abdou <[EMAIL PROTECTED] ..>
> To: [EMAIL PROTECTED] ups.com
> Sent: Wednesday, February 6, 2008 6:19:31 PM
> Subject: Re: [flexcoders] Re: is this how to use commitProperties
>
> and for measure() it only talks about the component itself so would
it be better to set a button(Child of the component) in the measure or
just do it in the createChildren( );
>
>
> ----- Original Message ----
> From: rueter007 <[EMAIL PROTECTED] co.uk>
> To: [EMAIL PROTECTED] ups.com
> Sent: Wednesday, February 6, 2008 5:57:18 PM
> Subject: [flexcoders] Re: is this how to use commitProperties
>
>
> you definitely can. but if there are several properties and each of
> them call invalidateDisplayLi st(), it could be a slight performance
> problem as you are redrawing for every change. Instead if you do it in
> the commitProperties, you call it once for all the changes.
>
> - venkat
> http://www.venkatj. com
>
> --- In [EMAIL PROTECTED] ups.com, Sherif Abdou <sherif626@ ..> wrote:
> >
> > so why not just call invalidateDisplayLi st() on the setter itself.
> Thanks
> > /**
> > * Used to Determine whether or not there was a change in the Close
> Policy
> > */
> > private var _closePolicyChanged :Boolean;
> > /**
> > * Internal Value for the ClosePolicy so we can react
> > * accordingly
> > */
> > private var _closePolicy: String;
> >
> [Inspectable( defaultValue= "close_always" ,enumeration=
"close_always, close_rollover, close_never, close_selected" )]
> > public function set closePolicy( value:String) :void{
> > if(_closePolicy !=value){
> > trace(value) ;
> > _closePolicy= value;
> > _closePolicyChanged =true;
> > invalidatePropertie s();
> > dispatchEvent( new Event("closePolicyC hanged")) ;
> > }
> > }
> > [Bindable(event= "closePolicyChan ged")]
> > public function get closePolicy( ):String{
> > return _closePolicy;
> > }
> > /**
> > * Create the CommitProperties so we determine if there is a need
> > * to change the closePolicy Buttons
> > */
> > override protected function commitProperties( ):void{
> > super.commitPropert ies();
> > if(_closePolicyChan ged){
> > closeButton. visible=true;
> > invalidateDisplayLi st();
> > _closePolicyChanged =false;
> > }
> > }
> >
> >
> >
> > ----- Original Message ----
> > From: ben.clinkinbeard <ben.clinkinbeard@ ...>
> > To: [EMAIL PROTECTED] ups.com
> > Sent: Wednesday, February 6, 2008 2:42:41 PM
> > Subject: [flexcoders] Re: is this how to use commitProperties
> > Looks right to me except you should validate that the new value is
> > actually different than the existing value in your setter before
> > setting the flag and whatnot.
> >
> > HTH,
> > Ben
> >
> > --- In [EMAIL PROTECTED] ups.com, Sherif Abdou <sherif626@ ..>
wrote:
> > >
> > > my bad, i for some reason sent it to flexComponents instead instead
> > of flexcoders so sorry for double post
> > > i am just wondering if this is how it usually gets used
> > > /**
> > > * Used to Determine whether or not there was a change in the Close
> > Policy
> > > */
> > > private var _closePolicyChanged :Boolean;
> > > /**
> > > * Internal Value for the ClosePolicy so we can react
> > > * accordingly
> > > */
> > > private var _closePolicy: String;
> > > [Inspectable( defaultValue= "close_always" ,enumeration=
> "close_always ,
> > close_rollover , close_never, close_selected" )]
> > > public function set closePolicy( value:String) :void{
> > > _closePolicy= value;
> > > _closePolicyChanged =true;
> > > this.invalidateProp erties();
> > > dispatchEvent( new Event("closePolicyC hanged")) ;
> > > }
> > > [Bindable(event= "closePolicyChan ged")]
> > > public function get closePolicy( ):String{
> > > return _closePolicy;
> > > }
> > >
> > > /**
> > > * Create the CommitProperties so we determine if there is a need
> > > * to change the closePolicy Buttons
> > > */
> > > override protected function commitProperties( ):void{
> > > super.commitPropert ies();
> > > if(_closePolicyChan ged){
> > > invalidateDisplayLi st();
> > > _closePolicyChanged =false;
> > > }
> > > }
> > >
> > >
> > >
> > ____________ _________ _________ _________ _________ _________ _
> > > Be a better friend, newshound, and
> > > know-it-all with Yahoo! Mobile. Try it now.
> > http://mobile. yahoo.com/ ;_ylt=Ahu06i62sR 8HDtDypao8Wcj9tA cJ
> > >
> >
> >
> >
> >
> >
> >
> ____________ _________ _________ _________ _________ _________ _
> > Looking for last minute shopping deals?
> > Find them fast with Yahoo! Search.
> http://tools. search.yahoo. com/newsearch/ category. php?category=
shopping
> >
>
>
>
>
>
>
>
> Looking for last minute shopping deals? Find them fast with Yahoo!
Search.
>
>
>
>
____________ _________ _________ _________ _________ _________ _
> Be a better friend, newshound, and
> know-it-all with Yahoo! Mobile. Try it now.
http://mobile. yahoo.com/ ;_ylt=Ahu06i62sR 8HDtDypao8Wcj9tA cJ
>
____________________________________________________________________________________
Never miss a thing. Make Yahoo your home page.
http://www.yahoo.com/r/hs