[flexcoders] Flex/Cairngorm Syntax
HiI am just embarking on my first Cairngorm based Flex app. In one of the sample apps there is the following syntaxpublic function onResult(event:* = null):void{}Could somebody please explain exactly what the argument "(event:* = null)" is actually doing. Obviously the argument is called 'event', I have got that far. Is the asterisk a wildcard for the type, and if so why, and is the null a default value if the argument is not supplied?I have had a look around the web and the docs but can't find any explanation of this syntax. What is more, I am not getting it to work but as I don't understand what it is supposed to be I'm not sure where the problem lies.Thanks for your help in advance...Graham __._,_.___ -- 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 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. __,_._,___
Re: [flexcoders] Flex/Cairngorm Syntax
Hi Graham, you're exactly right, * is a wildcard, meaning the parameter event that is passed to the function, can be of any type. By default, if not passed in, it is assumed NULL. This also is written somewhere in the docs but at the moment, I can'T remember where it was. Cheers, Thomas Thomas Rühl Design, Programming Concepts akitogo OHG Hanauer Landstrasse 188 60314 Frankfurt Telefon +49 (0) 69 800 69 445 Fax +49 (0) 69 800 69 449 Mobil +49 (0) 179 750 75 87 E-Mail [EMAIL PROTECTED] Web http://www.akitogo.com grahampengelly wrote: Hi I am just embarking on my first Cairngorm based Flex app. In one of the sample apps there is the following syntax public function onResult(event:* = null):void { } Could somebody please explain exactly what the argument (event:* = null) is actually doing. Obviously the argument is called 'event', I have got that far. Is the asterisk a wildcard for the type, and if so why, and is the null a default value if the argument is not supplied? I have had a look around the web and the docs but can't find any explanation of this syntax. What is more, I am not getting it to work but as I don't understand what it is supposed to be I'm not sure where the problem lies. Thanks for your help in advance... Graham -- 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] Flex/Cairngorm Syntax
Graham I see someone else answered your question, but... you might also want to look at Darron's page which talks about the Cairngorm Responder vs the Flex IResponder: http://www.darronschall.com/weblog/archives/000234.cfm The onResult(event:* = null):void method you asked about tells me you're using/learning the pure Cairngorm architecture which employs a Cairngorm Responder to get the data from the Delegate/Service back to the initial Command. Darron's page explains an alternative, IResponder, that is already part of the Flex API. It does the same thing, but it's more flexible, simpler to use, and easier to understand (just my opinion). I'm using it in all my new Cairngorm apps. I have yet to find a reason not to. Darren From: grahampengelly [EMAIL PROTECTED] Reply-To: flexcoders@yahoogroups.com To: flexcoders@yahoogroups.com Subject: [flexcoders] Flex/Cairngorm Syntax Date: Tue, 15 Aug 2006 13:02:35 - Hi I am just embarking on my first Cairngorm based Flex app. In one of the sample apps there is the following syntax public function onResult(event:* = null):void { } Could somebody please explain exactly what the argument (event:* = null) is actually doing. Obviously the argument is called 'event', I have got that far. Is the asterisk a wildcard for the type, and if so why, and is the null a default value if the argument is not supplied? I have had a look around the web and the docs but can't find any explanation of this syntax. What is more, I am not getting it to work but as I don't understand what it is supposed to be I'm not sure where the problem lies. Thanks for your help in advance... Graham -- 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] Flex/Cairngorm Syntax
Title: Re: [flexcoders] Flex/Cairngorm Syntax The * is an approximation of the Object keyword. Can be any type. Im not sure whether the typing is preserved or not but im sure Matt can confirm this. In effect event is cast as any object rather than having a strongly typed function call. Be aware in doing this though as type coercion issues may occur later on when dealing with the result. Since all event classes usually subclass from Event, you might use Event rather than * for type safety. Regards Samuel On 15/8/06 15:02, grahampengelly [EMAIL PROTECTED] wrote: Hi I am just embarking on my first Cairngorm based Flex app. In one of the sample apps there is the following syntax public function onResult(event:* = null):void { } Could somebody please explain exactly what the argument (event:* = null) is actually doing. Obviously the argument is called 'event', I have got that far. Is the asterisk a wildcard for the type, and if so why, and is the null a default value if the argument is not supplied? I have had a look around the web and the docs but can't find any explanation of this syntax. What is more, I am not getting it to work but as I don't understand what it is supposed to be I'm not sure where the problem lies. Thanks for your help in advance... Graham __._,_.___ -- 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. __,_._,___
Re: [flexcoders] Flex/Cairngorm Syntax
Actually... in Cairngorm, if a Command implements Responder the Command *must* contain: public function onResult( event : * = null ) : void {} public function onFault( event : * = null ) : void {} ...and if a Command implements IResponder that changes to public function result( event : Object ) : void {} public function fault( event : Object ) : void {} So in Graham's case, if he's using vanilla Cairngorm 2.0 his Commands are implemeting Responder, so he can't use Event in place of *... if he goes to Cairngorm 2.01 (my numbering, not a real thing) and uses IResponder he can use an Object type for the arg... but to use any other arg type (like event : Event) the Command would need to implement some totally new Responder class. Darren From: Samuel D. Colak [EMAIL PROTECTED] Reply-To: flexcoders@yahoogroups.com To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] Flex/Cairngorm Syntax Date: Tue, 15 Aug 2006 18:52:07 +0200 The * is an approximation of the Object keyword. Can be any type. Im not sure whether the typing is preserved or not but im sure Matt can confirm this. In effect event is cast as any object rather than having a strongly typed function call. Be aware in doing this though as type coercion issues may occur later on when dealing with the result. Since all event classes usually subclass from Event, you might use Event rather than * for type safety. Regards Samuel On 15/8/06 15:02, grahampengelly [EMAIL PROTECTED] wrote: Hi I am just embarking on my first Cairngorm based Flex app. In one of the sample apps there is the following syntax public function onResult(event:* = null):void { } Could somebody please explain exactly what the argument (event:* = null) is actually doing. Obviously the argument is called 'event', I have got that far. Is the asterisk a wildcard for the type, and if so why, and is the null a default value if the argument is not supplied? I have had a look around the web and the docs but can't find any explanation of this syntax. What is more, I am not getting it to work but as I don't understand what it is supposed to be I'm not sure where the problem lies. Thanks for your help in advance... Graham -- 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] Flex/Cairngorm Syntax
You can learn more about the * datatype here: http://livedocs.macromedia.com/flex/2/docs/1826.html Default parameters are described here: http://livedocs.macromedia.com/flex/2/docs/1834.html HTH, Matt From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Samuel D. Colak Sent: Tuesday, August 15, 2006 9:52 AM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] Flex/Cairngorm Syntax The * is an approximation of the Object keyword. Can be any type. Im not sure whether the typing is preserved or not but im sure Matt can confirm this. In effect event is cast as any object rather than having a strongly typed function call. Be aware in doing this though as type coercion issues may occur later on when dealing with the result. Since all event classes usually subclass from Event, you might use Event rather than * for type safety. Regards Samuel On 15/8/06 15:02, grahampengelly [EMAIL PROTECTED]ultants.com wrote: Hi I am just embarking on my first Cairngorm based Flex app. In one of the sample apps there is the following syntax public function onResult(event:* = null):void { } Could somebody please explain exactly what the argument (event:* = null) is actually doing. Obviously the argument is called 'event', I have got that far. Is the asterisk a wildcard for the type, and if so why, and is the null a default value if the argument is not supplied? I have had a look around the web and the docs but can't find any explanation of this syntax. What is more, I am not getting it to work but as I don't understand what it is supposed to be I'm not sure where the problem lies. Thanks for your help in advance... Graham __._,_.___ -- 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. __,_._,___