Re: [flexcoders] Re: is this how to use commitProperties
copy and paste straight from flex onto hear - Original Message From: Cato Paus <[EMAIL PROTECTED]> To: flexcoders@yahoogroups.com Sent: Sunday, February 10, 2008 5:24:52 AM Subject: [flexcoders] Re: is this how to use commitProperties Hi duds where do you get the code colors from ? --- In [EMAIL PROTECTED] ups.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 > Never miss a thing. Make Yahoo your home page. http://www.yahoo.com/r/hs
[flexcoders] Re: is this how to use commitProperties
Hi duds where do you get the code colors from ? --- In flexcoders@yahoogroups.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.invalidateProperties(); > dispatchEvent(new Event("closePolicyChanged")); > } > [Bindable(event="closePolicyChanged")] > 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.commitProperties(); > if(_closePolicyChanged){ > invalidateDisplayList(); > _closePolicyChanged=false; > } > } > > > __ __ > Be a better friend, newshound, and > know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ >
RE: [flexcoders] Re: is this how to use commitProperties
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: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Sherif Abdou Sent: Friday, February 08, 2008 5:08 PM To: flexcoders@yahoogroups.com 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: flexcoders@yahoogroups.com 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 lik
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: flexcoders@yahoogroups.com 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 [mailto:flexcoders@ yahoogroups. com] On Behalf Of Sherif Abdou Sent: Thursday, February 07, 2008 10:36 AM To: [EMAIL PROTECTED] 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 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():voi
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: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Sherif Abdou Sent: Thursday, February 07, 2008 10:36 AM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] Re: is this how to use commitProperties so good? bad? any opinions? - Original Message From: Sherif Abdou <[EMAIL PROTECTED]> To: flexcoders@yahoogroups.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
Re: [flexcoders] Re: is this how to use commitProperties
but wouldnt that take more memory? - Original Message From: Eric Cancil <[EMAIL PROTECTED]> To: flexcoders@yahoogroups.com Sent: Thursday, February 7, 2008 1:50:16 PM Subject: Re: [flexcoders] Re: is this how to use commitProperties It may be more code - But not only is it best practices, it's also using the framework to your advantage, and is far more efficient. On Feb 7, 2008 2:19 PM, Merrill, Jason wrote: My opinion is that is a lot of code to wade through! Jason Merrill Bank of America GT&O L&LD Solutions Design & Development eTools & Multimedia Bank of America Flash Platform Developer Community From: [EMAIL PROTECTED] ups.com [mailto:[EMAIL PROTECTED] ups.com] On Behalf Of Sherif Abdou Sent: Thursday, February 07, 2008 1:36 PM To: [EMAIL PROTECTED] 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 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 measu
Re: [flexcoders] Re: is this how to use commitProperties
It may be more code - But not only is it best practices, it's also using the framework to your advantage, and is far more efficient. On Feb 7, 2008 2:19 PM, Merrill, Jason <[EMAIL PROTECTED]> wrote: >My opinion is that is a lot of code to wade through! > > > Jason Merrill > *Bank of America * > GT&O L&LD Solutions Design & Development > eTools & Multimedia > > *Bank of America Flash Platform Developer Community* > > > -- > *From:* flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] *On > Behalf Of *Sherif Abdou > *Sent:* Thursday, February 07, 2008 1:36 PM > *To:* flexcoders@yahoogroups.com > > *Subject:* Re: [flexcoders] Re: is this how to use commitProperties > > so good? bad? any opinions? > > - Original Message > From: Sherif Abdou <[EMAIL PROTECTED]> > To: flexcoders@yahoogroups.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 f
RE: [flexcoders] Re: is this how to use commitProperties
My opinion is that is a lot of code to wade through! Jason Merrill Bank of America GT&O L&LD Solutions Design & Development eTools & Multimedia Bank of America Flash Platform Developer Community From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Sherif Abdou Sent: Thursday, February 07, 2008 1:36 PM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] Re: is this how to use commitProperties so good? bad? any opinions? - Original Message From: Sherif Abdou <[EMAIL PROTECTED]> To: flexcoders@yahoogroups.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
Re: [flexcoders] Re: is this how to use commitProperties
so good? bad? any opinions? - Original Message From: Sherif Abdou <[EMAIL PROTECTED]> To: flexcoders@yahoogroups.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(_close
Re: [flexcoders] Re: is this how to use commitProperties
ancedTabConstant.CLOSE_ROLLOVER: if(AdvancedTabConstant.TAB_ROLLED_OVER){ closeButton.visible=true; }else{ closeButton.visible=false; } } invalidateDisplayList(); _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("tabCloseButtonStyleName"); //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; invalidateProperties(); super.rollOverHandler(event); } override protected function rollOutHandler(event:MouseEvent):void{ AdvancedTabConstant.TAB_ROLLED_OVER=false; _closePolicyChanged=true; invalidateProperties(); super.rollOutHandler(event); } } } - Original Message ---- From: ecancil <[EMAIL PROTECTED]> To: flexcoders@yahoogroups.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, 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 > Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping
[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 flexcoders@yahoogroups.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.invalidateProperties(); > dispatchEvent(new Event("closePolicyChanged")); > } > [Bindable(event="closePolicyChanged")] > 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.commitProperties(); > if(_closePolicyChanged){ > invalidateDisplayList(); > _closePolicyChanged=false; > } > } > > > > Be a better friend, newshound, and > know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ >
Re: [flexcoders] Re: is this how to use commitProperties
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: flexcoders@yahoogroups.com 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://
[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 invalidateDispayList 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 flexcoders@yahoogroups.com, Sherif Abdou <[EMAIL PROTECTED]> wrote: > > and would something like this call the invalidateDisplayList() 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.commitProperties(); > if(_closePolicyChanged){ > closeButton.visible=true; > invalidateDisplayList(); > _closePolicyChanged=false; > } > if(_buttonDisplayChange){ > invalidateDisplayList(); > } > if(true){ > invalidateDisplayList(); > } > } > > > > - Original Message > From: Sherif Abdou <[EMAIL PROTECTED]> > To: flexcoders@yahoogroups.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 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 > > 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 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;
Re: [flexcoders] Re: is this how to use commitProperties
and would something like this call the invalidateDisplayList() 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.commitProperties(); if(_closePolicyChanged){ closeButton.visible=true; invalidateDisplayList(); _closePolicyChanged=false; } if(_buttonDisplayChange){ invalidateDisplayList(); } if(true){ invalidateDisplayList(); } } - Original Message From: Sherif Abdou <[EMAIL PROTECTED]> To: flexcoders@yahoogroups.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 <[EMAIL PROTECTED] ..> 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 > 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 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; > > } > > } > > > > > > > _ _ _ _
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]> To: flexcoders@yahoogroups.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 <[EMAIL PROTECTED] ..> 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 > 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 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 > Never miss a thing. Make Yahoo your home page. http://www.yahoo.com/r/hs
[flexcoders] Re: is this how to use commitProperties
there are also more advantages to using commitProperties when you have properties that depend on one another. Probably not a big deal in your example. http://livedocs.adobe.com/labs/flex3/html/help.html?content=ascomponents_advanced_3.html --- In flexcoders@yahoogroups.com, "rueter007" <[EMAIL PROTECTED]> wrote: > > you definitely can. but if there are several properties and each of > them call invalidateDisplayList(), 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 flexcoders@yahoogroups.com, Sherif Abdou wrote: > > > > so why not just call invalidateDisplayList() 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; > > invalidateProperties(); > > dispatchEvent(new Event("closePolicyChanged")); > > } > > } > > [Bindable(event="closePolicyChanged")] > > 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.commitProperties(); > > if(_closePolicyChanged){ > > closeButton.visible=true; > > invalidateDisplayList(); > > _closePolicyChanged=false; > > } > > } > > > > > > > > - Original Message > > From: ben.clinkinbeard > > To: flexcoders@yahoogroups.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 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 > > >
[flexcoders] Re: is this how to use commitProperties
you definitely can. but if there are several properties and each of them call invalidateDisplayList(), 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 flexcoders@yahoogroups.com, Sherif Abdou <[EMAIL PROTECTED]> wrote: > > so why not just call invalidateDisplayList() 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; > invalidateProperties(); > dispatchEvent(new Event("closePolicyChanged")); > } > } > [Bindable(event="closePolicyChanged")] > 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.commitProperties(); > if(_closePolicyChanged){ > closeButton.visible=true; > invalidateDisplayList(); > _closePolicyChanged=false; > } > } > > > > - Original Message ---- > From: ben.clinkinbeard <[EMAIL PROTECTED]> > To: flexcoders@yahoogroups.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 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 >
Re: [flexcoders] Re: is this how to use commitProperties
so why not just call invalidateDisplayList() 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; invalidateProperties(); dispatchEvent(new Event("closePolicyChanged")); } } [Bindable(event="closePolicyChanged")] 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.commitProperties(); if(_closePolicyChanged){ closeButton.visible=true; invalidateDisplayList(); _closePolicyChanged=false; } } - Original Message From: ben.clinkinbeard <[EMAIL PROTECTED]> To: flexcoders@yahoogroups.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 <[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 > Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping
[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 flexcoders@yahoogroups.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.invalidateProperties(); > dispatchEvent(new Event("closePolicyChanged")); > } > [Bindable(event="closePolicyChanged")] > 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.commitProperties(); > if(_closePolicyChanged){ > invalidateDisplayList(); > _closePolicyChanged=false; > } > } > > > > Be a better friend, newshound, and > know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ >