[flexcoders] Re: Flex2 ButtonBar; Can its buttons be individually enabled or disabled?
Mike, thanks for the reply. I made a couple of attempts at casting to a button but I must be missing something. Here is a simple example of what I'm talking about. If any row is selected in dg, then all buttons except button A should be disabled. What do I need to do to make this happen? Thanks, Bill... ?xml version=1.0 encoding=utf-8? mx:Application xmlns:mx=http://www.adobe.com/2006/mxml xmlns=* layout=vertical mx:Script ![CDATA[ import mx.events.ItemClickEvent; import mx.events.ListEvent; private function btnbarEvent(event:ItemClickEvent):void{ ta.text=btnbar selected index is +event.index.toString(); } private function dgEvent(event:ListEvent):void{ ta.text=dg selected index is +event.rowIndex.toString(); } ]] /mx:Script mx:DataGrid id=dg itemClick=dgEvent(event) mx:dataProvider mx:ArrayCollection mx:source mx:Object item=Something descr=Some thing/ mx:Object item=Nothing descr=No thing/ /mx:source /mx:ArrayCollection /mx:dataProvider /mx:DataGrid mx:ButtonBar id=btnbar itemClick=btnbarEvent(event) mx:dataProvider mx:Array mx:StringA/mx:String mx:StringB/mx:String mx:StringC/mx:String mx:StringD/mx:String /mx:Array /mx:dataProvider /mx:ButtonBar mx:TextArea id=ta width=200 height=100/ /mx:Application --- In flexcoders@yahoogroups.com, Michael Schmalle [EMAIL PROTECTED] wrote: Hi, Did you cast the returned button instance to Button? var child:Button = getChildAt(buttonIndex) as Button; Peace, Mike On 4/20/06, wlbagent [EMAIL PROTECTED] wrote: I know this can be done using individual buttons but can the individual buttons in a ButtonBar component (not the whole ButtonBar) be enabled or disabled? For example. You have a ButtonBar with 4 buttons labeled A,B,C,and D. You want button A to always be enabled but the remaining buttons would be enabled or disabled based on some other condition. You might have a DataGrid and want B,C,and D enabled if a row is selected, otherwise they are disabled. This should be a fairly easy thing to do if its actually possible. I can reference the individual buttons but there doesn't seem to be an enabled property for them. What have I missed?? Any ideas??? -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com SPONSORED LINKS Web site design developmenthttp://groups.yahoo.com/gads?t=msk=Web+site+design+developmentw1=Web+site+design+developmentw2=Computer+software+developmentw3=Software+design+and+developmentw4=Macromedia+flexw5=Software+development+best+practicec=5s=166.sig=L-4QTvxB_quFDtMyhrQaHQ Computer software developmenthttp://groups.yahoo.com/gads?t=msk=Computer+software+developmentw1=Web+site+design+developmentw2=Computer+software+developmentw3=Software+design+and+developmentw4=Macromedia+flexw5=Software+development+best+practicec=5s=166.sig=lvQjSRfQDfWudJSe1lLjHw Software design and developmenthttp://groups.yahoo.com/gads?t=msk=Software+design+and+developmentw1=Web+site+design+developmentw2=Computer+software+developmentw3=Software+design+and+developmentw4=Macromedia+flexw5=Software+development+best+practicec=5s=166.sig=1pMBCdo3DsJbuU9AEmO1oQ Macromedia flexhttp://groups.yahoo.com/gads?t=msk=Macromedia+flexw1=Web+site+design+developmentw2=Computer+software+developmentw3=Software+design+and+developmentw4=Macromedia+flexw5=Software+development+best+practicec=5s=166.sig=OO6nPIrz7_EpZI36cYzBjw Software development best practicehttp://groups.yahoo.com/gads?t=msk=Software+development+best+practicew1=Web+site+design+developmentw2=Computer+software+developmentw3=Software+design+and+developmentw4=Macromedia+flexw5=Software+development+best+practicec=5s=166.sig=f89quyyulIDsnABLD6IXIw -- YAHOO! GROUPS LINKS - Visit your group flexcodershttp://groups.yahoo.com/group/flexcoders on the web. - To unsubscribe from this group, send an email to: [EMAIL PROTECTED][EMAIL PROTECTED] - Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service http://docs.yahoo.com/info/terms/. -- -- What goes up, does come down. -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com SPONSORED LINKS Web site design development Computer software development Software design and development Macromedia flex Software development best practice YAHOO! GROUPS LINKS Visit your group
Re: [flexcoders] Re: Flex2 ButtonBar; Can its buttons be individually enabled or disabled?
You need to import the Button class, and then you can try something like this: ?xml version=1.0 encoding=utf-8? mx:Application xmlns:mx=http://www.adobe.com/2006/mxml xmlns=* layout=vertical mx:Script ![CDATA[ import mx.events.ItemClickEvent; import mx.events.ListEvent; // Add this import import mx.controls.Button; private function btnbarEvent(event:ItemClickEvent):void{ ta.text=btnbar selected index is +event.index.toString(); } private function dgEvent(event:ListEvent):void{ ta.text=dg selected index is +event.rowIndex.toString(); var childA:Button= btnbar.getChildAt(0) as Button; var childB:Button= btnbar.getChildAt(1) as Button; var childC:Button= btnbar.getChildAt(2) as Button; var childD:Button= btnbar.getChildAt(3) as Button; childB.enabled=false; childC.enabled=false; childD.enabled=false; } ]] /mx:Script mx:DataGrid id=dg itemClick=dgEvent(event) mx:dataProvider mx:ArrayCollection mx:source mx:Object item=Something descr=Some thing/ mx:Object item=Nothing descr=No thing/ /mx:source /mx:ArrayCollection /mx:dataProvider /mx:DataGrid mx:ButtonBar id=btnbar itemClick=btnbarEvent(event) mx:dataProvider mx:Array mx:StringA/mx:String mx:StringB/mx:String mx:StringC/mx:String mx:StringD/mx:String /mx:Array /mx:dataProvider /mx:ButtonBar mx:TextArea id=ta width=200 height=100/ /mx:Application |-+- | | | | | wlbagent | | | [EMAIL PROTECTED] | | | Sent by: | | | flexcoders@yahoogroups.com | | | 04/24/2006 09:07 AM | | | Please respond to | | | flexcoders | | | | |-+- -| | | | To: flexcoders@yahoogroups.com | | cc: | | Subject: [flexcoders] Re: Flex2 ButtonBar; Can its buttons be individually enabled or disabled? | -| Mike, thanks for the reply. I made a couple of attempts at casting to a button but I must be missing something. Here is a simple example of what I'm talking about. If any row is selected in dg, then all buttons except button A should be disabled. What do I need to do to make this happen? Thanks, Bill... ?xml version=1.0 encoding=utf-8? mx:Application xmlns:mx=http://www.adobe.com/2006/mxml xmlns=* layout=vertical mx:Script ![CDATA[ import mx.events.ItemClickEvent; import mx.events.ListEvent; private function btnbarEvent(event:ItemClickEvent):void{ ta.text=btnbar selected index is +event.index.toString(); } private function dgEvent(event:ListEvent):void{ ta.text=dg selected index is +event.rowIndex.toString(); } ]] /mx:Script mx:DataGrid id=dg itemClick=dgEvent(event) mx:dataProvider mx:ArrayCollection mx:source mx:Object item=Something descr=Some thing/ mx:Object item=Nothing descr=No thing/ /mx:source /mx:ArrayCollection /mx:dataProvider /mx:DataGrid mx:ButtonBar id=btnbar itemClick=btnbarEvent(event) mx:dataProvider mx:Array mx:StringA/mx:String mx:StringB/mx:String mx:StringC/mx:String mx:StringD/mx:String /mx:Array /mx:dataProvider /mx:ButtonBar mx:TextArea id=ta width=200 height=100/ /mx:Application --- In flexcoders@yahoogroups.com, Michael Schmalle [EMAIL PROTECTED] wrote: Hi, Did you cast the returned button instance to Button? var child:Button = getChildAt(buttonIndex) as Button; Peace, Mike On 4/20/06, wlbagent [EMAIL PROTECTED] wrote: I know this can be done using individual buttons but can the individual buttons in a ButtonBar component (not the whole ButtonBar) be enabled or disabled? For example. You have a ButtonBar with 4 buttons labeled A,B,C,and D. You want button A to always be enabled but the remaining buttons would be enabled or disabled based on some other condition. You might have a DataGrid and want B,C,and D enabled if a row is selected, otherwise they are disabled. This should be a fairly easy thing to do if its actually possible. I can reference the individual buttons but there doesn't seem to be an enabled property for them. What have I missed?? Any ideas??? -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com SPONSORED LINKS Web site design development http://groups.yahoo.com/gads?t=msk=Web+site+design+developmentw1=Web+site+design+developmentw2=Computer+software+developmentw3=Software+design+and+developmentw4=Macromedia+flexw5=Software+development+best+practicec=5s=166.sig=L-4QTvxB_quFDtMyhrQaHQ Computer software development http://groups.yahoo.com/gads?t=msk=Computer+software+developmentw1=Web+site+design+developmentw2=Computer+software+developmentw3=Software+design+and+developmentw4=Macromedia+flexw5=Software+development+best+practicec=5s=166.sig
[flexcoders] Re: Flex2 ButtonBar; Can its buttons be individually enabled or disabled?
Thanks, Oscar (and Mike). This does answer my question. I was looking for something more dynamic, though, in case buttons were added or removed. I'll tinker a bit more (btnbar.numChildren, etc) but thanks for the jump start. Bill... --- In flexcoders@yahoogroups.com, [EMAIL PROTECTED] wrote: You need to import the Button class, and then you can try something like this: ?xml version=1.0 encoding=utf-8? mx:Application xmlns:mx=http://www.adobe.com/2006/mxml xmlns=* layout=vertical mx:Script ![CDATA[ import mx.events.ItemClickEvent; import mx.events.ListEvent; // Add this import import mx.controls.Button; private function btnbarEvent(event:ItemClickEvent):void{ ta.text=btnbar selected index is +event.index.toString(); } private function dgEvent(event:ListEvent):void{ ta.text=dg selected index is +event.rowIndex.toString(); var childA:Button= btnbar.getChildAt(0) as Button; var childB:Button= btnbar.getChildAt(1) as Button; var childC:Button= btnbar.getChildAt(2) as Button; var childD:Button= btnbar.getChildAt(3) as Button; childB.enabled=false; childC.enabled=false; childD.enabled=false; } ]] /mx:Script mx:DataGrid id=dg itemClick=dgEvent(event) mx:dataProvider mx:ArrayCollection mx:source mx:Object item=Something descr=Some thing/ mx:Object item=Nothing descr=No thing/ /mx:source /mx:ArrayCollection /mx:dataProvider /mx:DataGrid mx:ButtonBar id=btnbar itemClick=btnbarEvent(event) mx:dataProvider mx:Array mx:StringA/mx:String mx:StringB/mx:String mx:StringC/mx:String mx:StringD/mx:String /mx:Array /mx:dataProvider /mx:ButtonBar mx:TextArea id=ta width=200 height=100/ /mx:Application |-+- | | | | | wlbagent | | | [EMAIL PROTECTED] | | | Sent by: | | | flexcoders@yahoogroups.com | | | 04/24/2006 09:07 AM | | | Please respond to | | | flexcoders | | | | |-+- -| | | | To: flexcoders@yahoogroups.com | | cc: | | Subject: [flexcoders] Re: Flex2 ButtonBar; Can its buttons be individually enabled or disabled? | -| Mike, thanks for the reply. I made a couple of attempts at casting to a button but I must be missing something. Here is a simple example of what I'm talking about. If any row is selected in dg, then all buttons except button A should be disabled. What do I need to do to make this happen? Thanks, Bill... ?xml version=1.0 encoding=utf-8? mx:Application xmlns:mx=http://www.adobe.com/2006/mxml xmlns=* layout=vertical mx:Script ![CDATA[ import mx.events.ItemClickEvent; import mx.events.ListEvent; private function btnbarEvent(event:ItemClickEvent):void{ ta.text=btnbar selected index is +event.index.toString(); } private function dgEvent(event:ListEvent):void{ ta.text=dg selected index is +event.rowIndex.toString(); } ]] /mx:Script mx:DataGrid id=dg itemClick=dgEvent(event) mx:dataProvider mx:ArrayCollection mx:source mx:Object item=Something descr=Some thing/ mx:Object item=Nothing descr=No thing/ /mx:source /mx:ArrayCollection /mx:dataProvider /mx:DataGrid mx:ButtonBar id=btnbar itemClick=btnbarEvent(event) mx:dataProvider mx:Array mx:StringA/mx:String mx:StringB/mx:String mx:StringC/mx:String mx:StringD/mx:String /mx:Array /mx:dataProvider /mx:ButtonBar mx:TextArea id=ta width=200 height=100/ /mx:Application --- In flexcoders@yahoogroups.com, Michael Schmalle teoti.graphix@ wrote: Hi, Did you cast the returned button instance to Button? var child:Button = getChildAt(buttonIndex) as Button; Peace, Mike On 4/20/06, wlbagent wlbagent@ wrote: I know this can be done using individual buttons but can the individual buttons in a ButtonBar component (not the whole ButtonBar) be enabled or disabled? For example. You have a ButtonBar with 4 buttons labeled A,B,C,and D. You want button A to always be enabled but the remaining buttons would be enabled or disabled based on some other condition. You might have a DataGrid and want B,C,and D enabled if a row is selected, otherwise they are disabled. This should be a fairly easy thing to do if its actually possible. I can reference the individual buttons but there doesn't seem to be an enabled property for them. What have I missed?? Any ideas??? -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com SPONSORED LINKS Web site design development http://groups.yahoo.com/gads?t=msk=Web+site+design+developmentw1=Web+site+design+developmentw2