SetEventHandler which you can use to change event handlers at runtime.
Define a state in your app:
<mx:states>
<mx:State name="state1">
<mx:SetEventHandler name="click" target="{button1}"
handler=" closeState()"/>
</mx:State>
</mx:states>
In your actionscript code, you can set currentState = "state1" which
will change the click handler of the button to closeState().
button1.label = "Exit";
button2.label = "Print";
currentState = "state1";
BTW, you can also set label properties on buttons inside State tag using
SetProperty tag.
Thanks
-Ashish
> -----Original Message-----
> From: [email protected] [mailto:[EMAIL PROTECTED]
On
> Behalf Of Gordon Smith
> Sent: Tuesday, May 23, 2006 2:47 PM
> To: [email protected]
> Subject: RE: [flexcoders] Re: Chaning the click event on a button
>
> > what I need to do is repalce that click event with another click
event
>
>
> You can use removeEventListener() to remove an event handler added by
> addEventListener(). But I don't think it is trivial to remove a
handler
> declared via an MXML event attribute, because the actual handler name
is
> autogenerated. If this is what you are doing, rewrite it to use
> addEventListener() for both handlers.
>
> - Gordon
>
>
> -----Original Message-----
> From: [email protected] [mailto:[EMAIL PROTECTED]
On
> Behalf Of Jeremy Rottman
> Sent: Tuesday, May 23, 2006 2:25 PM
> To: [email protected]
> Subject: [flexcoders] Re: Chaning the click event on a button
>
> On my button I already have one click event, what I need to do is
> repalce that click event with another click event based off of an if
> statment. Here is my code for that if statement.
>
> public function StatusModcheckStatusQryResult(result){
> if (result.status == 'Pending'){
> ClosingDisplayModcloseResQry(result.fileNum);
>
> }
> else if (result.status == 'Closed'){
>
> ClosingDisplayModdisplayClosingQry(result.fileNum);
> button1.label = "Exit";
> button2.label = "Print";
> button1.addEventListener(MouseEvent.CLICK,
> closeState);
> }
> }
>
>
> --- In [email protected], "Gordon Smith" <[EMAIL PROTECTED]> wrote:
> >
> > myButton.addEventListener(MouseEvent.CLICK, doThisFunction);
> >
> > Note that there are no parens on doThisFunction. You are passing a
> reference-to-this-handler to addEventListener(), not calling the
> handler.
> >
> > - Gordon
> >
> >
> > -----Original Message-----
> > From: [email protected] [mailto:[EMAIL PROTECTED]
> On Behalf Of Jeremy Rottman
> > Sent: Tuesday, May 23, 2006 2:03 PM
> > To: [email protected]
> > Subject: [flexcoders] Chaning the click event on a button
> >
> > Is it possible to change the click event on a button through
> > actionscript. IE something like this.
> >
> > myButton.click = doThisFunction();
> >
> >
> >
> >
> >
> >
> >
> > --
> > 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
> >
>
>
>
>
>
>
>
>
> --
> 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
>
>
>
>
>
>
>
>
> ------------------------ Yahoo! Groups Sponsor
>
> --
> 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
>
>
>
>
>
--
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 "flexcoders" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.

