  | |  | where to set default values in a AS2 class | where to set default values in a AS2 class 2004-02-11 - By Andreas Weber
Back I love default values - those little helpers which are just there, even if you haven't sent in anything (would be lovely if bank accounts would work this way...). But where should they be set in a custom AS2 class?
Here's an example, with too different ways to set the (imaginary) width and height property of the instance:
class Test{ private var __width:Number = 50; private var __height:Number;
function Test(){ init(); }
private function init(){ height = 100; }
function set width(width:Number):Void{ __width = width; } function get width():Number{ return __width; } function set height(height:Number):Void{ __height = height; } function get height():Number{ return __height; } }
// in the .fla file: var myTest:Test = new Test();
trace(myTest.width);// Output: 50 trace(myTest.height);// Output: 100
__width is set when the var is initialized and typed. __height is set through the constructor/init method, calling the setter method.
Another possibility maybe: making the default values static (class members vs. instance members)?
Best practice? Pros and cons?
TIA! (I guess the answer could serve as a sample chapter for the books Jesse and Darron should write...)
-- ---- ------ Andreas Weber motiondraw.com
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------ Supported by Fig Leaf Software -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------ Lower Prices for Certified Training! Check out new lower prices for Certified Macromedia Training from Fig Leaf Software. Expand your skill set with courses in ColdFusion, Flash, Rich Internet Applications and .NET in the new year. Fig Leaf Software provides the highest caliber instruction at our training centers in Washington D.C., Atlanta, Chicago, Baltimore, Northern Virginia, or on-site at your location.
Get the details at http://training.figleaf.com/ -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- To unsubscribe, e-mail: flashnewbie-unsubscribe@(protected) For additional commands, e-mail: flashnewbie-help@(protected)
Earn $52 per hosting referral at Lunarpages.
|
|
 |