[Flashcoders] Inconsistent Constant
In the following example should maxHeight and maxWidth be constants? If not, why? class Box { //accessing a static property through a method. //The box class, with methods to set and retreive the //value of the class property, numSides. // //The class property numSides private static var numSides:Number = 4; // private var width:Number; private var height:Number; private var area:Number; // //all CAPS denotes constants, values that never change. private static var DEFAULT_WIDTH:Number = 30; private static var DEFAULT_HEIGHT:Number = 20; //SHOULD THESE BE CONSTANT public static var maxWidth = 250; public static var maxHeight = 250; // //The constructor function. public function Box(w:Number, h:Number) { if (w == undefined) { w = DEFAULT_WIDTH; } if (h == undefined) { h = DEFAULT_HEIGHT; } width = w; height = h; //initialize area. This is perfectly legal within a constructor area = width*height; } //Method for setting numSides. public function setNumSides(newNumSides:Number):Void { numSides = newNumSides; } //Method for getting numSides. public function getNumSides():Number { return numSides; } } ___ Flashcoders@chattyfig.figleaf.com 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
Re: [Flashcoders] Inconsistent Constant
Chris... Firstly - Flash doesn't have the concept of constants, so you couldn't enforce a constant even if you wanted to (except by a hack like defining a null set() function, but that's beside the point a bit)... you can only suggest that specific things should be constant by convention i.e. tell all your coders to treat variables in capitals as constant and not to change their values. Secondly - who knows? Those variables aren't actually referred to in the code except for on their defining lines. They could be used for absolutely anything at all. You'd need to be much clearer on the purpose of those variables before anyone could tell you if they 'should' be constant. But see my first paragraph. I could answer more fully if I knew why you were asking, and what the values were actually supposed to be... Ian On 3/20/06, Chris [EMAIL PROTECTED] wrote: In the following example should maxHeight and maxWidth be constants? If not, why? class Box { //accessing a static property through a method. //The box class, with methods to set and retreive the //value of the class property, numSides. // //The class property numSides private static var numSides:Number = 4; // private var width:Number; private var height:Number; private var area:Number; // //all CAPS denotes constants, values that never change. private static var DEFAULT_WIDTH:Number = 30; private static var DEFAULT_HEIGHT:Number = 20; //SHOULD THESE BE CONSTANT public static var maxWidth = 250; public static var maxHeight = 250; // //The constructor function. public function Box(w:Number, h:Number) { if (w == undefined) { w = DEFAULT_WIDTH; } if (h == undefined) { h = DEFAULT_HEIGHT; } width = w; height = h; //initialize area. This is perfectly legal within a constructor area = width*height; } //Method for setting numSides. public function setNumSides(newNumSides:Number):Void { numSides = newNumSides; } //Method for getting numSides. public function getNumSides():Number { return numSides; } } ___ Flashcoders@chattyfig.figleaf.com 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
Re: [Flashcoders] Inconsistent Constant
Ian, Flash doesn't have the concept of constants, so you couldn't enforce a constant even if you wanted to (except by a hack like defining a null set() function, but that's beside the point a bit)... you can only suggest that specific things should be constant by convention It's not really beside the point. We define constants in this way... class Test { public static function get SOME_CONSTANT():String { return value; } } ...which works perfectly. -- Steve Webster Head of Development Featurecreep Ltd. http://www.featurecreep.com 14 Orchard Street, Bristol, BS1 5EH 0117 905 5047 ___ Flashcoders@chattyfig.figleaf.com 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
Fwd: [Flashcoders] Inconsistent Constant
Ian, Flash doesn't have the concept of constants, so you couldn't enforce a constant even if you wanted to (except by a hack like defining a null set() function, but that's beside the point a bit)... you can only suggest that specific things should be constant by convention It's not really beside the point. We define constants in this way... class Test { public static function get SOME_CONSTANT():String { return value; } } ...which works perfectly. PS. Sorry if I sounded a little short in the above e-mail; I sent it in a hurry and forgot to add relevant smilies :o) -- Steve Webster Head of Development Featurecreep Ltd. http://www.featurecreep.com 14 Orchard Street, Bristol, BS1 5EH 0117 905 5047 ___ Flashcoders@chattyfig.figleaf.com 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
RE: [Flashcoders] Inconsistent Constant
I agree with that. I set constants like that so I cant overwrite them on accident. Jim -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Steve Webster Sent: 20 March 2006 17:36 To: Flashcoders mailing list Subject: Re: [Flashcoders] Inconsistent Constant Ian, Flash doesn't have the concept of constants, so you couldn't enforce a constant even if you wanted to (except by a hack like defining a null set() function, but that's beside the point a bit)... you can only suggest that specific things should be constant by convention It's not really beside the point. We define constants in this way... class Test { public static function get SOME_CONSTANT():String { return value; } } ...which works perfectly. -- Steve Webster Head of Development Featurecreep Ltd. http://www.featurecreep.com 14 Orchard Street, Bristol, BS1 5EH 0117 905 5047 ___ Flashcoders@chattyfig.figleaf.com 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 ___ Flashcoders@chattyfig.figleaf.com 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
Re: [Flashcoders] Inconsistent Constant
Steve, Fine. :-) My two-second thought works, then. Haven't tried that, but may well start using it - it only just occurred to me as a method as I was writing the post. :-) I stand corrected. :-) That doesn't gainsay the second part of the posting - there really isn't enough detail in that original post to answer the poster's question. Ian On 3/20/06, Steve Webster [EMAIL PROTECTED] wrote: Ian, Flash doesn't have the concept of constants, so you couldn't enforce a constant even if you wanted to (except by a hack like defining a null set() function, but that's beside the point a bit)... you can only suggest that specific things should be constant by convention It's not really beside the point. We define constants in this way... class Test { public static function get SOME_CONSTANT():String { return value; } } ...which works perfectly. ___ Flashcoders@chattyfig.figleaf.com 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
RE: [Flashcoders] Inconsistent Constant
Just a quick note on this. There are ways to prevent variables from being overwritten. ASSetPropFlags. Here is a description as to its usage. http://www.flashguru.co.uk/assetpropflags/ It's kind of strange, but it's useful once and awhile. Scott -Original Message- From: [EMAIL PROTECTED] on behalf of Jim Tann Sent: Mon 3/20/2006 1:27 PM To: Flashcoders mailing list Cc: Subject:RE: [Flashcoders] Inconsistent Constant I agree with that. I set constants like that so I cant overwrite them on accident. Jim -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Steve Webster Sent: 20 March 2006 17:36 To: Flashcoders mailing list Subject: Re: [Flashcoders] Inconsistent Constant Ian, Flash doesn't have the concept of constants, so you couldn't enforce a constant even if you wanted to (except by a hack like defining a null set() function, but that's beside the point a bit)... you can only suggest that specific things should be constant by convention It's not really beside the point. We define constants in this way... class Test { public static function get SOME_CONSTANT():String { return value; } } ...which works perfectly. -- Steve Webster Head of Development Featurecreep Ltd. http://www.featurecreep.com 14 Orchard Street, Bristol, BS1 5EH 0117 905 5047 ___ Flashcoders@chattyfig.figleaf.com 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 ___ Flashcoders@chattyfig.figleaf.com 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 ___ Flashcoders@chattyfig.figleaf.com 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