Hi Alex, I stopped playing with ViewHelpers in the 80% of the cases. I was overloading the use of ViewHelpers and thank God I soon realized of that. To make more reusable components, I prefer embeding script code into the mxml file, use reusable commands (this was discussed in another thread) and dispatch events from the same component. Talking about the other 20% of cases, I use your (and some other guys) approach of dispatching events from the parent view or the main application that both extend display objects.
Thanks again for your help and please read my new post about Cairngorm and memory Im just writing in a sec hehe Alberto Albericio Salvador Aura S.A. Seguros Departamento Informática Alex Uhlmann escribió: > Hi Alberto, > > When dispatching events you have to be sure that the object you call > dispatchEvent from is a display object (all display objects extend > flash.events.EventDispatcher) and is on the display list. i.e. as Dirk > mentioned you can call the dispatchEvent method in your MXML file because it > is on the display list and extends EventDispatcher. If you want to trigger a > Cairngorm Command with your call you could access the most parent display > object your application in mx.core.Application.application. So, > Application.application.dispatchEvent(event);. From your View Helper, I would > just access the view of your MXML file to dispatch an event. Flex then uses > event bubbling and triggers the registered Command. > > Best, > Alex > > Alex Uhlmann > Technical Consultant (Rich Internet Applications) > Adobe Consulting > Westpoint, 4 Redheughs Rigg, South Gyle, Edinburgh, EH12 9DQ, UK > p: +44 (0) 131 338 6969 > m: +44 (0) 7917 428 951 > [EMAIL PROTECTED] > > > -----Original Message----- > From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of > Alberto Albericio Salvador > Sent: 14 February 2006 13:16 > To: [email protected] > Subject: Re: [flexcoders] Dispatching events from cairngorm viewhelper > > Joao, > > Im using cairngorm 2a2 and my event extends CairngormEvent but the problem is > not with the event but with dispatchEvent method: > > Im meaning, in this function, LocalidadesEvent extends CairngormEvent > > public function getPoblaciones(cp:String):void { > var event : LocalidadesEvent = new LocalidadesEvent(cp); > dispatchEvent(event); > } > > But I get the error: > > Call to a possibly undefined method 'dispatchEvent' > > Im using the same code in the main view and in the helper and it should work, > but it doesnt. > > Alberto Albericio Salvador > Aura S.A. Seguros > Departamento Informática > > > > João Fernandes escribió: > >> OK if you are using cairngorm 2alpha2 you should be able to use it >> like this >> >> In your viewhelper you should import the new cairngormEvent "import >> org.nevis.cairngorm.control.CairngormEvent" >> And your event should extend cairngormEvent >> >> It should work, >> >> João Fernandes >> Sistemas de Informação >> >> Programador Informático >> Cofina media >> >> Avenida João Crisóstomo, Nº 72 . 1069-043 Lisboa PORTUGAL Tel (+351) >> 213 185 200 . Fax (+351) 213 540 370 [EMAIL PROTECTED] >> >> >> -----Original Message----- >> From: [email protected] [mailto:[EMAIL PROTECTED] >> On Behalf Of Alberto Albericio Salvador >> Sent: terça-feira, 14 de Fevereiro de 2006 12:46 >> To: [email protected] >> Subject: Re: [flexcoders] Dispatching events from cairngorm viewhelper >> >> Hi Joao, >> >> Im working with Flex2b1 and I dont import anything, neither in the >> main view nor in my custom viewhelper. >> >> Anyway, importing that continues throwing the error: >> >> Call to a possibly undefined method 'dispatchEvent' >> >> Alberto Albericio Salvador >> Aura S.A. Seguros >> Departamento Informática >> >> >> >> João Fernandes escribió: >> >> >>> Alberto, >>> >>> Did you import mx.events.EventDispatcher? >>> >>> João Fernandes >>> Sistemas de Informação >>> Programador Informático >>> Cofina media >>> >>> Avenida João Crisóstomo, Nº 72 . 1069-043 Lisboa PORTUGAL Tel (+351) >>> 213 185 200 . Fax (+351) 213 540 370 [EMAIL PROTECTED] >>> >>> -----Original Message----- >>> From: [email protected] [mailto:[EMAIL PROTECTED] >>> On Behalf Of Alberto Albericio Salvador >>> Sent: terça-feira, 14 de Fevereiro de 2006 12:19 >>> To: [email protected] >>> Subject: [flexcoders] Dispatching events from cairngorm viewhelper >>> >>> Hi all, >>> >>> When trying to dispatch an event from a custom class that extends >>> cairngorm ViewHelper, I get this error: >>> >>> >> Call to a possibly undefined method 'dispatchEvent' >>> >>> Firing the event from a function of the main view, same code, it works fine. >>> >>> My function is something like, same in the view and in my custom viewhelper. >>> >>> public function getPoblaciones(cp:String):void { >>> var event : LocalidadesEvent = new LocalidadesEvent(cp); >>> dispatchEvent(event); } >>> >>> Has anybody run into this issue? >>> >>> >>> >>> >> -- >> 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 >> >> >> >> >> >> >> >> >> > > > -- > 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 > > > > > > > > > -- 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 <*> To visit your group on the web, go to: http://groups.yahoo.com/group/flexcoders/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/

