Thanks guys, it works great!!! awesome! However, it doesn't work to get x and y postion for textinput component. do you have any ideas of this?
I may need to fix this as soon as possible, I am appreciate if you guys have any suggestions. Cheers & THANKS ================================================================ <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"> <mx:Script> <![CDATA[ import flash.events.MouseEvent; import mx.controls.Alert; private function getHandler(evt:MouseEvent):void { var alert:Alert; //Alert.show("the position of LABEL 1 'x' is "+event.currentTarget.x, "Show Me", Alert.YES | Alert.NO) Alert.show("the position of LABEL 1 'x' is "+evt.currentTarget.x, "Show Me", Alert.YES | Alert.NO) } ]]> </mx:Script> <mx:Form> <mx:FormItem label="Label"> <mx:TextInput id="label1" click="getHandler(event)"/> </mx:FormItem> <mx:FormItem label="Label"> <mx:TextInput/> </mx:FormItem> <mx:FormItem label="Labe3"> <mx:TextInput/> </mx:FormItem> </mx:Form> <!-- <mx:Button id="IAMAButton1" label="validate" click="getHandler(event)" /> <mx:Button id="IAMAButton2" label="validate" click="getHandler(event)" /> <mx:Button id="IAMAButton3" label="validate" click="getHandler(event)" /> --> </mx:Application> ================================================================ *Forwarded Conversation* Subject: *Flex - How to get button ID name?* ------------------------ * From: macromedia flash* <[EMAIL PROTECTED]> To: [email protected] Date: Sat, Sep 8, 2007 at 5:02 PM Hi there, I am working on Flex and need to get the button ID in function, do you have any ideas? <?xml version="1.0" encoding="utf-8"?> <!-- FLEX 2 SOLUTION --> <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"> <mx:Script> <![CDATA[ private function getHandler():void{ //how to get the button ID name here => IAMAButton "x" ? } ]]> </mx:Script> <mx:Button id="IAMAButton1" label="validate" click="getHandler()" /> <mx:Button id="IAMAButton2" label="validate" click="getHandler()" /> <mx:Button id="IAMAButton3" label="validate" click="getHandler()" /> </mx:Application> -------- * From: ben gomez farrell* <[EMAIL PROTECTED]> Reply-To: [email protected] To: [email protected] Date: Sat, Sep 8, 2007 at 5:22 PM OK I'm still new to Flex, but as I've been playing with it all day, I think I can answer this. Your click function is coded in such a way that you've ignored the event coming coming in. Yah, "getHandler" gets called on click, but there's some more details you could get when it gets clicked. Here's how I'd do it: <mx:Button id="IAMAButton1" label="validate" click="getHandler(event.target.id)" /> private function getHandler( id:String ):void { trace(id); } Or you could pass in the whole target: click="getHandler(event.target)" and get it in the getHandler(target:Button) by doing trace(target.id); That help? ben [Quoted text hidden] > _______________________________________________ > [email protected] > To change your subscription options or search the archive: > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > > Brought to you by Fig Leaf Software > Premier Authorized Adobe Consulting and Training > http://www.figleaf.com > http://training.figleaf.com > > _______________________________________________ [email protected] To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com -------- * From: Muzak* <[EMAIL PROTECTED]> Reply-To: [email protected] To: [email protected] Date: Sat, Sep 8, 2007 at 7:28 PM <mx:Script> <![CDATA[ import flash.events.MouseEvent; private function clickHandler(evt:MouseEvent):void { trace(evt.currentTarget.id); } ]]> </mx:Script> <mx:Button id="IAMAButton1" label="validate" click="clickHandler(event)" /> <mx:Button id="IAMAButton2" label="validate" click="clickHandler(event)" /> <mx:Button id="IAMAButton3" label="validate" click="clickHandler(event)" /> You should probably consider joining FlexCoders: http://tech.groups.yahoo.com/group/flexcoders/ regards, Muzak [Quoted text hidden] [Quoted text hidden] -------- * From: Brian Lesser* <[EMAIL PROTECTED]> Reply-To: [email protected] To: [email protected] Date: Sat, Sep 8, 2007 at 7:42 PM In general it is probably better, and more common, to pass the event and let the method decide what it needs from it: <mx:Button id="IAMAButton1" label="validate" click="getHandler(event)" /> private function getHandler( event:MouseEvent ):void { trace(event.target.id); } Yours truly, -Brian [Quoted text hidden] -- ______________________________________________________________________ Brian Lesser Assistant Director, Application Development and Integration Computing and Communications Services Ryerson University 350 Victoria St. Toronto, Ontario Phone: (416) 979-5000 ext. 6835 M5B 2K3 Fax: (416) 979-5220 Office: POD?? E-mail: [EMAIL PROTECTED] (Enter through LB99) Web: http://www.ryerson.ca/~blesser<http://www.ryerson.ca/%7Eblesser> ______________________________________________________________________ [Quoted text hidden] -------- _______________________________________________ [email protected] To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com

