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:String>A</mx:String>
                                                 <mx:String>B</mx:String>
                                                 <mx:String>C</mx:String>
                                                 <mx:String>D</mx:String>
                                     </mx:Array>
                         </mx:dataProvider>
             </mx:ButtonBar>
             <mx:TextArea id="ta" width="200" height="100"/>
</mx:Application>





|---------+----------------------------->
|         |                             |
|         |  "wlbagent"                 |
|         |  <[EMAIL PROTECTED]>       |
|         |  Sent by:                   |
|         |  [email protected] |
|         |  04/24/2006 09:07 AM        |
|         |  Please respond to          |
|         |  flexcoders                 |
|         |                             |
|---------+----------------------------->
  >-----------------------------------------------------------------------------------------------------------------------------|
  |                                                                                                                             |
  |      To: [email protected]                                                                                         |
  |      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:String>A</mx:String>
                                                 <mx:String>B</mx:String>
                                                 <mx:String>C</mx:String>
                                                 <mx:String>D</mx:String>
                                     </mx:Array>
                         </mx:dataProvider>
             </mx:ButtonBar>
             <mx:TextArea id="ta" width="200" height="100"/>
</mx:Application>


--- In [email protected], "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=ms&k=Web+site+design+development&w1=Web+site+design+development&w2=Computer+software+development&w3=Software+design+and+development&w4=Macromedia+flex&w5=Software+development+best+practice&c=5&s=166&.sig=L-4QTvxB_quFDtMyhrQaHQ
>
Computer
> > software
development<
http://groups.yahoo.com/gads?t=ms&k=Computer+software+development&w1=Web+site+design+development&w2=Computer+software+development&w3=Software+design+and+development&w4=Macromedia+flex&w5=Software+development+best+practice&c=5&s=166&.sig=lvQjSRfQDfWudJSe1lLjHw
>
Software
> > design and
development<
http://groups.yahoo.com/gads?t=ms&k=Software+design+and+development&w1=Web+site+design+development&w2=Computer+software+development&w3=Software+design+and+development&w4=Macromedia+flex&w5=Software+development+best+practice&c=5&s=166&.sig=1pMBCdo3DsJbuU9AEmO1oQ
>
  Macromedia
> >
flex<
http://groups.yahoo.com/gads?t=ms&k=Macromedia+flex&w1=Web+site+design+development&w2=Computer+software+development&w3=Software+design+and+development&w4=Macromedia+flex&w5=Software+development+best+practice&c=5&s=166&.sig=OO6nPIrz7_EpZI36cYzBjw
>
Software
> > development best
practice<
http://groups.yahoo.com/gads?t=ms&k=Software+development+best+practice&w1=Web+site+design+development&w2=Computer+software+development&w3=Software+design+and+development&w4=Macromedia+flex&w5=Software+development+best+practice&c=5&s=166&.sig=f89quyyulIDsnABLD6IXIw
>
> >  ------------------------------
> > YAHOO! GROUPS LINKS
> >
> >
> >    -  Visit your group
"flexcoders<http://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
Yahoo! Groups Links











---------------------------------------------------------------------------
This e-mail message (including attachments, if any) is intended for the use
of the individual or entity to which it is addressed and may contain
information that is privileged, proprietary , confidential and exempt from
disclosure.  If you are not the intended recipient, you are notified that
any dissemination, distribution or copying of this communication is
strictly prohibited.  If you have received this communication in error,
please notify the sender and erase this e-mail message immediately.
---------------------------------------------------------------------------




--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




YAHOO! GROUPS LINKS




Reply via email to