Fred,

Use event targets, look how easy it is, works from any button, you can use 
casting...

HTH,
Patrick


import mx.controls.Button;
                        
                        
                        
                        private function changeStyle(e:MouseEvent):void
                        {
                                var b:Button = e.currentTarget as Button;

                                        if (b.getStyle("fontStyle")=="normal") 
                                        {
                                b.setStyle("fontSize",18)
                                b.setStyle("fontWeight","bold")
                                         } else {
        
                                b.setStyle("fontSize",10)
                                b.setStyle("fontWeight","normal")
                        }
                                }
                        }
                        
                ]]>
        </mx:Script>
        <mx:Button  click="changeStyle(event)"/>
        <mx:Button  click="changeStyle(event)"/>
        <mx:Button  click="changeStyle(event)"/>




--- In flexcoders@yahoogroups.com, duraibalaji <duraibal...@...> wrote:
>
> 
> <?xml version="1.0"?>
> 
> <!--hi Fred, i'm trying to explain what i understood in flex, i don't know
> your knowledge on other scriptings.
> 
> As a flex developer, we know that all of our files are complied generated as
> actionscript files and then converted into swf files that funs in flash
> which runs in the client machine.
> 
> Application is the property that holds the entire view which is from xml
> namespace with mx from http://www.adobe.com/2006/mxml-->
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";>
> 
> <!--the below are the scripting area where we can right our own scripts that
> controls the mx other properties that we define for application view -->
>   <mx:Script><![CDATA[
>       /* naming the font style and size */
>     private var newFontStyle:String;
>     private var newFontSize:int;
>       /* we have given a function called changeLabel which is called on click
> property that we have mentiond in the Button view */
>     public function changeLabel(s:String):void {
>       /* get the Name of the button that has to be changed. '+s' is 1 or 2
> from the click function called  and then String Name as myButton1 or
> myButton2*/
>         s = "myButton"+s;
>        /* check and change the style and size of the Button */
>         if (this[s].getStyle("fontStyle")=="normal") {
>             newFontStyle = "italic";
>             newFontSize = 18;
>         } else {
>             newFontStyle = "normal";
>             newFontSize = 10;    
>         }
>       /* Now set the latest value that is checked  */
>         this[s].setStyle("fontStyle",newFontStyle);
>         this[s].setStyle("fontSize",newFontSize);
>     }
>     ]]></mx:Script>
>       <!--Adding button to the application view with the properties like id,
> label and click-->
>     <mx:Button id="myButton1"
>         click="changeLabel('2')"
>         label="Change Other Button's Styles"
>     />
>     <mx:Button id="myButton2"
>         click="changeLabel('1')"
>         label="Change Other Button's Styles"
>     />
> </mx:Application> 
> 
> 
> 
> 
> Fred45 wrote:
> > 
> > 
> > 
> > <?xml version="1.0"?>
> > Can somebody explain into details what that code do?(line by line). I know
> > that it is changing the font size but I cannot understand the :"s"
> > and the "normal"? I understand the overal code but not everything. Thanks
> > again for your time. Fred.
> > <!-- usingas/FlexComponents.mxml -->
> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";>
> >   <mx:Script><![CDATA[
> >     private var newFontStyle:String;
> >     private var newFontSize:int;
> >   
> >     public function changeLabel(s:String):void {
> >         s = "myButton" + s;
> >         
> >         if (this[s].getStyle("fontStyle")=="normal") {
> >             newFontStyle = "italic";
> >             newFontSize = 18;
> >         } else {
> >             newFontStyle = "normal";
> >             newFontSize = 10;     
> >         }
> >      
> >         this[s].setStyle("fontStyle",newFontStyle);
> >         this[s].setStyle("fontSize",newFontSize);
> >     }
> >     ]]></mx:Script>
> > 
> >     <mx:Button id="myButton1" 
> >         click="changeLabel('2')" 
> >         label="Change Other Button's Styles"
> >     />
> >     <mx:Button id="myButton2" 
> >         click="changeLabel('1')" 
> >         label="Change Other Button's Styles"
> >     />
> > </mx:Application>
> > 
> > 
> > 
> > 
> 
> -- 
> View this message in context: 
> http://www.nabble.com/Simple-actionscript-that-I-cannot-understand%21-Please-help.-Thanks-tp22536950p22540167.html
> Sent from the FlexCoders mailing list archive at Nabble.com.
>


Reply via email to