The <mx:Component> tag is, let's call it... Voodoo :) What it's actually doing is defining a new custom component class, whereas every other MXML tag you use will define elements of the class defined in the root element of your MXML document. You can tell MXMLC what name you'd like the class to have in order to reuse it later, but otherwise it just picks an unused ugly name for you. So you need to think of everything inside your <mx:Component> tag as if it were in a completely separate MXML file. And becuase we don't have inner classes in ActionScript, you don't have access to members of the "parent" class the way you normally would expect to.
If your handler is on Application (and public) you can get to it from a renderer using Application.application.handler_resize(event). But I prefer to dispatch bubbling events from within the custom component, and then put listener code in the containing object. -Josh 2009/1/19 Paul Andrews <[email protected]> > ----- Original Message ----- > From: "dnk" <[email protected]> > To: "Flexcoder List" <[email protected]> > Sent: Sunday, January 18, 2009 5:47 PM > Subject: [flexcoders] flex not seeing method - update > > > > > > Ok, I found one additional piece of info that when I sent this I > > thought was not relevant. In my main.mxml, my component.mxml is > > actually an itemrenderer. So the code for it would be: > > > > > > <mx:itemRenderer> > > <mx:Component> > > <view:fileActions DownloadResizeEvent="handler_resize(event)"/> > > </mx:Component> > > </mx:itemRenderer> > > > > Instead of : > > <view:fileActions DownloadResizeEvent="handler_resize(event)"/> > > > > Now the reason this seems relevant is because if I comment out the > > item renderer code, and place just a single instance of my > > component.mxml in my main.mxml - it works fine. No more errors. > > > > So to sum up.... when a custom component that dispatches a custom > > event is placed within the above mxml code - it will not see the > > defined event handler. > > > > ideas? > > Try making the handler public.. > > > d > > > > > > > > > > Begin forwarded message: > > > >> From: dnk <[email protected]> > >> Date: January 18, 2009 9:35:46 AM PST (CA) > >> To: Flexcoder List <[email protected]> > >> Subject: flex not seeing method > >> > >> Hi there, I have an mxml component that dispatches an event. Now > >> when i use the component, the meta data is showing up fine. But when > >> i assign a handler, flex says that it is a call to a possibly > >> undefined method. But it is there plain as day. IDeas??? > >> > >> Code snippets below. > >> > >> DownloadResizeEvent.as - pretty stock custom event: > >> > >> package elib.event > >> { > >> > >> import flash.events.Event; > >> > >> public class DownloadResizeEvent extends Event > >> { > >> > >> public static const DOWNLOADRESIZE_EVENT:String = > >> "downloadresizeevent"; > >> > >> public function DownloadResizeEvent(type:String):void > >> { > >> super(type); > >> } > >> > >> // Override the inherited clone() method. > >> override public function clone():Event { > >> return new DownloadResizeEvent(type); > >> } > >> > >> } > >> } > >> > >> now in my component.mxml: > >> > >> (in a script block) > >> > >> <<<snip>>> > >> import elib.event.*; > >> <<<//snip>>> > >> > >> (in same script block) > >> > >> <<<snip>>> > >> //located in a method > >> dispatchEvent( new Event(DownloadResizeEvent.DOWNLOADRESIZE_EVENT) ); > >> > >> <<<//snip>>> > >> > >> Then later in my mxml > >> > >> <<<snip>>> > >> <mx:Metadata> > >> [Event(name="DownloadResizeEvent", > >> type="elib.event.DownloadResizeEvent")] > >> </mx:Metadata> > >> <<<//snip>>> > >> > >> > >> > >> > >> An now in my other mxml file that has my component.mxml called in it: > >> > >> main.mxml > >> > >> > >> (in my root tag) > >> > >> <<<snip>>> > >> xmlns:view="elib.view.components.*" > >> <<<//snip>>> > >> > >> > >> (in a script block) > >> > >> <<<snip>>> > >> import elib.event.*; > >> <<<//snip>>> > >> > >> (in same script block) > >> <<<snip>>> > >> //event handler > >> private function handler_resize(evt:Event):void { > >> > >> } > >> > >> <<<//snip>>> > >> > >> > >> > >> <<<snip>>> > >> <view:componentmxml DownloadResizeEvent="handler_resize(event)"/> > >> <<<//snip>>> > > > > > > ------------------------------------ > > > > -- > > Flexcoders Mailing List > > FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt > > Alternative FAQ location: > > > https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847 > > Search Archives: > > http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups > > Links > > > > > > > > > ------------------------------------ > > -- > Flexcoders Mailing List > FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt > Alternative FAQ location: > https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847 > Search Archives: > http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups > Links > > > > -- "Therefore, send not to know For whom the bell tolls. It tolls for thee." Like the cut of my jib? Check out my Flex blog! :: Josh 'G-Funk' McDonald :: 0437 221 380 :: [email protected] :: http://flex.joshmcdonald.info/ :: http://twitter.com/sophistifunk

