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

Reply via email to