Yes, you generally make invalidateXXX() calls in each setter. The
invalidateXXX() methods do almost no work and are designed for frequent
calling. They basically just set a flag and push the calling object onto
one of the LayoutManager's work queues. This makes them so lightweight
that setters can generally be called inside inner loops. The real work
gets done later during the revalidation performed by the LayoutManager.
 
Call invalidateProperties() in a setter if it needs commitProperties()
to get called once right before the next render.
 
Call invalidateSize() in a setter if it needs measure() to get called
once right before the next render.
 
Call invalidateDisplayList() in a setter if it needs updateDisplayList()
to get called once right before the next render.
 
Gordon Smith
Adobe Flex SDK Team

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Sherif Abdou
Sent: Friday, February 08, 2008 5:08 PM
To: [email protected]
Subject: Re: [flexcoders] Re: is this how to use commitProperties



ok so invalidate... in setters so i can have five setters and each one
ending with invalidate...


----- Original Message ----
From: Gordon Smith <[EMAIL PROTECTED]>
To: [email protected]
Sent: Friday, February 8, 2008 3:48:31 PM
Subject: RE: [flexcoders] Re: is this how to use commitProperties



Avoid calling invalidateXXX( ) inside commitProperties( ), measure(), or
updateDisplayList( ), as this can cause a second pass through the
LayoutManager to revalidate; invalidateXXX( ) is typically called by
property setters.
 
Gordon Smith
Adobe Flex SDK Team

________________________________

From: [EMAIL PROTECTED] ups.com <http://ups.com/>  [mailto:flexcoders@
yahoogroups. com] On Behalf Of Sherif Abdou
Sent: Thursday, February 07, 2008 10:36 AM
To: [EMAIL PROTECTED] ups.com <http://ups.com/> 
Subject: Re: [flexcoders] Re: is this how to use commitProperties



so good? bad? any opinions?


----- Original Message ----
From: Sherif Abdou <[EMAIL PROTECTED] com>
To: [EMAIL PROTECTED] ups.com <http://ups.com/> 
Sent: Wednesday, February 6, 2008 9:53:43 PM
Subject: Re: [flexcoders] Re: is this how to use commitProperties



if anyone cares to check, is this how your suppose to do the stuff or is
it overkill. This is a Tab that contains a Close Button so if the user
clicks on the close Button then the tab gets removed and depending on
the policy that gets picked it reacts.
package flexlib.controls. tabBarClasses

{

import flash.display. DisplayObject;

import flash.events. Event;

import flash.events. MouseEvent;

import flexlib.constants. AdvancedTabConst ant;

import flexlib.interfaces. ICustomComponent Styles;

import mx.controls. Button;

import mx.controls. tabBarClasses. Tab;

import mx.core.UIComponent ;

/**

* The Style For the Close Button that will be used

*/

[Style(name="tabCloseButtonStyl eName",type="String", inherit="no")]

/**

* The Style that is used for the indicator, it will be an image

*/

[Style(name="indicatorClass", type="String", inherit="no")]

public class AdvancedTab extends Tab implements ICustomComponentSty les

{

/**

* Flag to Know if the Button has been created or not

*/

private var _closeButtonCreated :Boolean;

/**

* The Button that will aid us in closing the Tab AKA removing it from
the scene

*/

private var closeButton: Button;

/**

* The Display Indicator that gets seen between the tabs when we move
them

*/

private var indicatorDisplay: UIComponent;

public function AdvancedTab( )

{

super();

//enable Mouse Children so we can Have Interaction with the Buttons

//and other Stuff that will be placed on the Tab, by Default it is false

//reason is if there is a textField in the Tab then a click may be
dispatched or

//heard in the textField instead of the Tab itself and sometimes you
dont want that to

//happen.

mouseChildren=true;

}

/**

* 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;

invalidatePropertie s();

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,onCloseBut
tonClickHandler) ;

//hide the close button

closeButton. visible=false;

_closeButtonCreated = true;

addChild(closeButto n);

}

/**

* 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(indicatorD isplay as DisplayObject) ;

}

//call to set the styles

setCustomStyles( );

}

/**

* Called On when the User Clicks on the Close Button,

* all we are going to do is dispatch that the user

* wants to close the tab and handle in the AdvanedTabBar

* so it gets removed cleanly

*/

private function onCloseButtonClickH andler(event: MouseEvent) :void{

dispatchEvent(new Event(AdvancedTabCo nstant.CLOSE_ TAB));

}

/**

* 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(_closeButtonCreate d){

closeButton. width = closeButton. height=16;

_closeButtonCreated =false;

}

}

/**

* The Sizes and Positions the Children

*/

override protected function updateDisplayList( unscaledWidth: Number,
unscaledHeight: Number):void{

super.updateDisplayList( unscaledWidth, unscaledHeight) ;

//check to see if we have the Button

if(closeButton. visible){

closeButton. move(unscaledWid th-closeButton. width,4);

//change the index of where the button is so we can adjust it

setChildIndex( closeButton, numChildren- 2);

}

if(indicatorDisplay) {

setChildIndex( indicatorDisplay ,numChildren- 1);

}

}

/**

* Create the CommitProperties so we determine if there is a need

* to change the closePolicy Buttons

*/

override protected function commitProperties( ):void{

super.commitProperties( );

if(_closePolicyChange d){

switch(closePolicy) {

case AdvancedTabConstant .CLOSE_ALWAYS:

closeButton. visible=true;

break;

case AdvancedTabConstant .CLOSE_NEVER:

closeButton. visible=false;

break;

case AdvancedTabConstant .CLOSE_SELECTED:

if(selected){

closeButton. visible=true;

}else{

closeButton. visible=false;

}

break;

case AdvancedTabConstant .CLOSE_ROLLOVER:

if(AdvancedTabConstan t.TAB_ROLLED_ OVER){

closeButton. visible=true;

}else{

closeButton. visible=false;

}

}

invalidateDisplayLi st();

_closePolicyChanged =false;

}

}

/**

* Sets The Custom Styles for The Indicator and for the button after they
have been created

*/

public function setCustomStyles( ):void{

//Set the Style of the Button here

closeButton. styleName = getStyle("tabCloseButtonStyl eName");

//set the Style of the Indicator Button here

indicatorDisplay.
setStyle("backgroundImage",getStyle("indicatorClass"));

}

/**

* Keep Track of When the User is over the Button

*/

override protected function rollOverHandler( event:MouseEvent ):void{

AdvancedTabConstant .TAB_ROLLED_ OVER = true;

_closePolicyChanged =true;

invalidatePropertie s();

super.rollOverHandler( event);

}

override protected function rollOutHandler( event:MouseEvent ):void{

AdvancedTabConstant .TAB_ROLLED_ OVER=false;

_closePolicyChanged =true;

invalidatePropertie s();

super.rollOutHandler( event);

}

}

}



----- Original Message ----
From: ecancil <[EMAIL PROTECTED] com>
To: [EMAIL PROTECTED] ups.com <http://ups.com/> 
Sent: Wednesday, February 6, 2008 7:46:45 PM
Subject: [flexcoders] Re: is this how to use commitProperties



it doesnt matter how many times you call invalidate - it will still
only do it once - that's the whole point.
--- In [EMAIL PROTECTED] ups.com <mailto:flexcoders%40yahoogroups.com>
, Sherif Abdou <[EMAIL PROTECTED] ..> 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
<http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAc! !%20J> 
>





________________________________

Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try
it now.
<http://us.rd.yahoo.com/evt=51733/*http://mobile.yahoo.com/;_ylt=Ahu06i6
2sR8HDtDypao8Wcj9tAcJ>  


________________________________

Never miss a thing. Make Yahoo your homepage.
<http://us.rd.yahoo.com/evt=51438/*http://www.yahoo.com/r/hs>  



________________________________

Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try
it now.
<http://us.rd.yahoo.com/evt=51733/*http://mobile.yahoo.com/;_ylt=Ahu06i6
2sR8HDtDypao8Wcj9tAcJ>  

 

Reply via email to