You can either do a variation on what Abdul said using target, or use 
Delegate to forward to different functions:


Smart click:

cancel_pb.addEventListener("click", this);
submit_pb.addEventListener("click", this);

function click(event_obj:Object):Void
{
switch(event_obj.target)
{
case cancel_pb:
// do cancel stuff;
break;

case submit_pb:
// do submit stuff
break;
}
}

Or, Delegate to forward:

import mx.utils.Delegate;
cancel_pb.addEventListener("click", Delegate.create(this, onCancel));
submit_pb.addEventListener("click", Delegate.create(this, onSubmit));

function onCancel(event_obj:Object):Void
{
// do cancel stuff
}

function onSubmit(event_obj:Object):Void
{
// do submit stuff
}


----- Original Message ----- 
From: "Abdul Qabiz" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Monday, February 07, 2005 8:42 AM
Subject: RE: [flexcoders] codeless MXML seprate AS class help



Hi Art,

I couldn't get what you are asking. Do you mean to have separate event
handler for all seven buttons in MXML?

What I interpret, you have seven buttons in mxml and one click function
handling the click events for those buttons. You can identify the button
clicked by using "event.target.id".


function click(event)
{
var target = event.target.id;

switch(id) {

case "button1":
//do something
break;
case "button2":
//do something
break;
case "button3":
//do something
break;
}
}




Does it help? Please give us more details?

-abdul



-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Monday, February 07, 2005 6:36 PM
To: [email protected]
Subject: [flexcoders] codeless MXML seprate AS class help


Hi All,

I'm trying to make my class seprate from my MXML. I'm following the simple
example founf in the docs but I've ran into one problem. How do I define
multiple click events from different buttons? I have 7 at the moment and for
the life of me I can't find an example w/ more than one button click
function.

thanks,
-Art




Yahoo! Groups Links









Yahoo! Groups Links








Reply via email to