Mailing List
Home
Forum Home
Flash Pro
Subjects
Firework Effect
setInterval bug identified and fixed
setInterval bug identified and fixed
ScrollPane component doesn 't auto update
Help: MX 2004 How to script a print button to print the entire sli
Event Dispatcher between classes
memory management removeMovieClip /
MX2004 Dataset itemClassName
Order of events per frame
XML to Object help
Textfield prototype question
Flash and QuickTime VR
Reading and displaying RSS feeds in Flash MX
Flash MX 2004 Sucks
AW: [Flashcoders] Switch/Case vs If/else
AW: [Flashcoders] Switch/Case vs If/else
Flash Interface with 10mb xml file
Web Service Results
Listener Object 's best practice
 
Search:  
Power your search with and, or, +, -, or "some phrase" operators.
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
Reply:     1     2     3     4     5     6     7     8     9     10  

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.