you mean like this or am i misunderstanding something
private function swapFunc():void
{
defaultButton=button2; 
}



----- Original Message ----
From: Carl Vorster <[EMAIL PROTECTED]>
To: [email protected]
Sent: Saturday, February 9, 2008 11:26:56 AM
Subject: RE: [flexcoders] Changing defaultButton programatically

Hi,
 
Maybe I’m not explaining properly…
 
Here’s some code; I’ve got three buttons in the code. With creation the default 
button is set to button1; so when I press enter, button1’s function is being 
called.
What I want to do is press the swap button and then change the default button 
from button1 to button2 so when I press enter, button2’s function is being 
called.
 
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe. com/2006/ mxml" layout="absolute"
                defaultButton="{button1}"
                                creationComplete="initApp()">
                
                <mx:Script>
                <![CDATA[
                import mx.controls. Alert;
 
                private function initApp():void
                {
                                focusManager. setFocus( field1);
                }
                
                private function func1():void
                {
                                Alert.show("Button 1");
                }
                
                private function func2():void
                {
                                Alert.show("Button 2");
                }
 
                private function swapFunc():void
                {
                                Alert.show("Default button swapped");
                }
 
                                ]]>
                </mx:Script>
                <mx:TextInput x="25" y="36" text="Text" width="207" 
id="field1"/>
                
                <mx:Button x="25" y="89"   label="One" id="button1" 
click="func1()"/>
                <mx:Button x="109" y="89" label="Two" id="button2" 
click="func2()"/>
                
                <mx:Button x="176" y="89" label="Swap" id="swap" 
click="swapFunc()"/>
                
                
                
</mx:Application>
 
 
Thanks
 
Car
 



From: [EMAIL PROTECTED] ups.com [mailto: [EMAIL PROTECTED] ups.com ] On Behalf 
Of Sherif Abdou
Sent: Saturday, February 09, 2008 6:49 PM
To: [EMAIL PROTECTED] ups.com
Subject: Re: [flexcoders] Changing defaultButton programatically
 
you can make that button invisible and the other visibile, have diffrent skins.
----- Original Message ----
From: Carl Vorster <carl.vorster@ gmail.com>
To: [EMAIL PROTECTED] ups.com
Sent: Saturday, February 9, 2008 9:26:24 AM
Subject: [flexcoders] Changing defaultButton programatically
Hi,
 
I’ve got a Panel with a default button, but would like to change the default 
button to another button when a certain event occurs.
 
Can someone point me in the right direction to do this?
 
Thanks in advance
 
Carl 
 
 



Never miss a thing. Make Yahoo your homepage. 



      
____________________________________________________________________________________
Looking for last minute shopping deals?  
Find them fast with Yahoo! Search.  
http://tools.search.yahoo.com/newsearch/category.php?category=shopping

Reply via email to