Re: [flexcoders] Cairngorm2 reusable commands
Thats it! I like it and it works 100%. Thanks Feiy! Alberto Albericio Salvador Aura S.A. Seguros Departamento Informática feiy escribió: u can extends the event,add a source attribute to it eg: public class SourceEvent extends CairngormEvent{ public SourceEvent(type:String,source:Object){ super(type); this.source=source ; } public var source:Object; } then inner the viewHelper: public function getResults():void { var event:SourceEvent=new SourceEvent(askForResult,this.view); dispatchEvent(event); } last,the command is knowed the events.source now! event.source.setResult... 2006/2/17, Alberto Albericio Salvador [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]: Hi all, In Cairngorm commands, I always define statically where I want some results to be sent (normally a custom function in component that extends ViewHelper). This updates my view and works fine. But... How can I make that command Class to send some results to whatever asked for them (who dispatched the event that threw that command)? Eg: foobar1.mxml and foobar2.mxml .. public function setResults(someResults):void { //update my controls } public function getResults():void { dispatchEvent(askForResults); } foobar1 and foobar2 dispatch the same event and the command needs to know where to send back the results and run setResults on the corresponding caller. How can I achieve this? Thanks in advance -- Alberto Albericio Salvador Aura S.A. Seguros Departamento Informática -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com SPONSORED LINKS Web site design development http://groups.yahoo.com/gads?t=msk=Web+site+design+developmentw1=Web+site+design+developmentw2=Computer+software+developmentw3=Software+design+and+developmentw4=Macromedia+flexw5=Software+development+best+practicec=5s=166.sig=L-4QTvxB_quFDtMyhrQaHQ Computer software development http://groups.yahoo.com/gads?t=msk=Computer+software+developmentw1=Web+site+design+developmentw2=Computer+software+developmentw3=Software+design+and+developmentw4=Macromedia+flexw5=Software+development+best+practicec=5s=166.sig=lvQjSRfQDfWudJSe1lLjHw Software design and development http://groups.yahoo.com/gads?t=msk=Software+design+and+developmentw1=Web+site+design+developmentw2=Computer+software+developmentw3=Software+design+and+developmentw4=Macromedia+flexw5=Software+development+best+practicec=5s=166.sig=1pMBCdo3DsJbuU9AEmO1oQ Macromedia flex http://groups.yahoo.com/gads?t=msk=Macromedia+flexw1=Web+site+design+developmentw2=Computer+software+developmentw3=Software+design+and+developmentw4=Macromedia+flexw5=Software+development+best+practicec=5s=166.sig=OO6nPIrz7_EpZI36cYzBjw Software development best practice http://groups.yahoo.com/gads?t=msk=Software+development+best+practicew1=Web+site+design+developmentw2=Computer+software+developmentw3=Software+design+and+developmentw4=Macromedia+flexw5=Software+development+best+practicec=5s=166.sig=f89quyyulIDsnABLD6IXIw YAHOO! GROUPS LINKS * Visit your group flexcoders http://groups.yahoo.com/group/flexcoders on the web. * To unsubscribe from this group, send an email to: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] * Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service http://docs.yahoo.com/info/terms/ . -- 闲云孤鹤 - 清冷香中抱膝吟 -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com SPONSORED LINKS Web site design development http://groups.yahoo.com/gads?t=msk=Web+site+design+developmentw1=Web+site+design+developmentw2=Computer+software+developmentw3=Software+design+and+developmentw4=Macromedia+flexw5=Software+development+best+practicec=5s=166.sig=L-4QTvxB_quFDtMyhrQaHQ Computer software development http://groups.yahoo.com/gads?t=msk=Computer+software+developmentw1=Web+site+design+developmentw2=Computer+software+developmentw3=Software+design+and+developmentw4=Macromedia+flexw5=Software+development+best+practicec=5s=166.sig=lvQjSRfQDfWudJSe1lLjHw Software design and development http://groups.yahoo.com/gads?t=msk=Software+design+and+developmentw1=Web+site+design+developmentw2=Computer+software+developmentw3=Software+design+and+developmentw4=Macromedia+flexw5=Software+development+best+practicec=5s=166.sig=1pMBCdo3DsJbuU9AEmO1oQ Macromedia flex
RE: [flexcoders] Cairngorm2 reusable commands
Alberto, In my opinion commands shouldn't be aware of the views. It's not what cairngorm is made for. Dispatch your event and set the result to some variable in your ModelLocator. Then if foobar1 and foobar2 need that info, use bindings and bind them to that variable ... Do you need to transform that information in a different way for each one? Fine, use the Foobar1ViewHelper and Foobar2ViewHelper to do it. Example: Foobar1.mxml mx:Script ![CDATA[ Import your.model.locator.path.ModelLocator; [Bindable] public var model:ModelLocator = ModelLocator.getInstance(); ]] /mx:Script mx:Combobox dataProvider={Foobar1ViewHelper.formatMyModel(model.myVar)}/ Foobar2.mxml mx:Combobox dataProvider={Foobar2ViewHelper.formatDifferentlyMyModel(model.myVar)}/ 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: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Alberto Albericio Salvador Sent: sexta-feira, 17 de Fevereiro de 2006 11:45 To: flexcoders@yahoogroups.com Subject: [flexcoders] Cairngorm2 reusable commands Hi all, In Cairngorm commands, I always define statically where I want some results to be sent (normally a custom function in component that extends ViewHelper). This updates my view and works fine. But... How can I make that command Class to send some results to whatever asked for them (who dispatched the event that threw that command)? Eg: foobar1.mxml and foobar2.mxml .. public function setResults(someResults):void { //update my controls } public function getResults():void { dispatchEvent(askForResults); } foobar1 and foobar2 dispatch the same event and the command needs to know where to send back the results and run setResults on the corresponding caller. How can I achieve this? Thanks in advance -- Alberto Albericio Salvador Aura S.A. Seguros Departamento Informática -- 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/
Re: [flexcoders] Cairngorm2 reusable commands
Hi Joao, I dont agree at all hehe For me, it is ok that commands know about views (or whatever dispatches the event that started that command) Imagine this situation: You have a screen where 2 components ask for the weather on a zip code, so I can see weather on 2 locations at the same time. What I say is: I need both components to dispatch the same event(getWeather) but with different parameter (zip code) and get the results back to them using the same command. I dont want to use a single application pool to store my results. Alberto Albericio Salvador Aura S.A. Seguros Departamento Informática João Fernandes escribió: Alberto, In my opinion commands shouldn't be aware of the views. It's not what cairngorm is made for. Dispatch your event and set the result to some variable in your ModelLocator. Then if foobar1 and foobar2 need that info, use bindings and bind them to that variable ... Do you need to transform that information in a different way for each one? Fine, use the Foobar1ViewHelper and Foobar2ViewHelper to do it. Example: Foobar1.mxml mx:Script ![CDATA[ Import your.model.locator.path.ModelLocator; [Bindable] public var model:ModelLocator = ModelLocator.getInstance(); ]] /mx:Script mx:Combobox dataProvider={Foobar1ViewHelper.formatMyModel(model.myVar)}/ Foobar2.mxml mx:Combobox dataProvider={Foobar2ViewHelper.formatDifferentlyMyModel(model.myVar)}/ 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: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Alberto Albericio Salvador Sent: sexta-feira, 17 de Fevereiro de 2006 11:45 To: flexcoders@yahoogroups.com Subject: [flexcoders] Cairngorm2 reusable commands Hi all, In Cairngorm commands, I always define statically where I want some results to be sent (normally a custom function in component that extends ViewHelper). This updates my view and works fine. But... How can I make that command Class to send some results to whatever asked for them (who dispatched the event that threw that command)? Eg: foobar1.mxml and foobar2.mxml .. public function setResults(someResults):void { //update my controls } public function getResults():void { dispatchEvent(askForResults); } foobar1 and foobar2 dispatch the same event and the command needs to know where to send back the results and run setResults on the corresponding caller. How can I achieve this? Thanks in advance -- 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/
RE: [flexcoders] Cairngorm2 reusable commands
I'll second this approach : 1. use as much as possible the Model Locator and bindings to avoid commandsviews dependencies, 2. when not sufficient or not elegant, use a viewhelper. Benoit Hediard (which was using too much viewhelpers at the begining ;) ) -Message d'origine- De : flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] De la part de João Fernandes Envoyé : vendredi 17 février 2006 13:08 À : flexcoders@yahoogroups.com Objet : RE: [flexcoders] Cairngorm2 reusable commands Alberto, In my opinion commands shouldn't be aware of the views. It's not what cairngorm is made for. Dispatch your event and set the result to some variable in your ModelLocator. Then if foobar1 and foobar2 need that info, use bindings and bind them to that variable ... Do you need to transform that information in a different way for each one? Fine, use the Foobar1ViewHelper and Foobar2ViewHelper to do it. Example: Foobar1.mxml mx:Script ![CDATA[ Import your.model.locator.path.ModelLocator; [Bindable] public var model:ModelLocator = ModelLocator.getInstance(); ]] /mx:Script mx:Combobox dataProvider={Foobar1ViewHelper.formatMyModel(model.myVar)}/ Foobar2.mxml mx:Combobox dataProvider={Foobar2ViewHelper.formatDifferentlyMyModel(model.myVar)}/ 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: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Alberto Albericio Salvador Sent: sexta-feira, 17 de Fevereiro de 2006 11:45 To: flexcoders@yahoogroups.com Subject: [flexcoders] Cairngorm2 reusable commands Hi all, In Cairngorm commands, I always define statically where I want some results to be sent (normally a custom function in component that extends ViewHelper). This updates my view and works fine. But... How can I make that command Class to send some results to whatever asked for them (who dispatched the event that threw that command)? Eg: foobar1.mxml and foobar2.mxml .. public function setResults(someResults):void { //update my controls } public function getResults():void { dispatchEvent(askForResults); } foobar1 and foobar2 dispatch the same event and the command needs to know where to send back the results and run setResults on the corresponding caller. How can I achieve this? Thanks in advance -- Alberto Albericio Salvador Aura S.A. Seguros Departamento Informática -- 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/
Re: [flexcoders] Cairngorm2 reusable commands
u can extends the event,add a source attribute to iteg:public class SourceEvent extends CairngormEvent{ public SourceEvent(type:String,source:Object){ super(type);this.source=source ; }public var source:Object;}then inner the viewHelper: public function getResults():void { var event:SourceEvent=new SourceEvent(askForResult,this.view); dispatchEvent(event); } last,the command is knowed the events.source now! event.source.setResult... 2006/2/17, Alberto Albericio Salvador [EMAIL PROTECTED]: Hi all, In Cairngorm commands, I always define statically where I want some results to be sent (normally a custom function in component that extends ViewHelper). This updates my view and works fine. But... How can I make that command Class to send some results to whatever asked for them (who dispatched the event that threw that command)? Eg: foobar1.mxml and foobar2.mxml .. public function setResults(someResults):void { //update my controls } public function getResults():void { dispatchEvent(askForResults); } foobar1 and foobar2 dispatch the same event and the command needs to know where to send back the results and run setResults on the corresponding caller. How can I achieve this? Thanks in advance -- Alberto Albericio Salvador Aura S.A. Seguros Departamento Informática -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com SPONSORED LINKS Web site design development Computer software development Software design and development Macromedia flex Software development best practice YAHOO! GROUPS LINKS Visit your group flexcoders on the web. To unsubscribe from this group, send an email to: [EMAIL PROTECTED] Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service . -- 闲云孤鹤 - 清冷香中抱膝吟 -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com SPONSORED LINKS Web site design development Computer software development Software design and development Macromedia flex Software development best practice YAHOO! GROUPS LINKS Visit your group "flexcoders" on the web. To unsubscribe from this group, send an email to:[EMAIL PROTECTED] Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.