Hi JesterXL,
my component consists of a viewstack with 1-"X" children. each child contains a
textfeild. 1 button adds a child, 1 removes a child, 1 maked the tf in a child
editable, the other 4 navigate through the viewstack.
so I can add this to my class?
public function click(event_obj:Object):Void
{
switch(event_obj.target)
{
case add_pb:
// create child in viewstack
break;case remove_pb: // do child in viewstack break;
case edit_pb: // do edit current tf in viewstack break;
case first_pb: // goto first child in view stack break;
case previous_pb: // goto previous child in viewstack break;
case next_pb: // goto next child in viewstack break;
case last_pb: // goto last child in viewstack break; } }
I'm trying to build my component based on the temperature converter sample. is this the best practice on doing this?
thanks, -Art
Quoting JesterXL <[EMAIL PROTECTED]>:
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
Yahoo! Groups Links

