This is the personal weblog of Greg Burch.

Monday, December 23, 2002

Busy with the holidays, work, and possibly buying a new home, so I have neglected everyone...I appologize :).

Most components (including the macromedia components) fail to provide defaults for component parameters. Forcing you to pass in an ugly initObj into attachMovie which usually requires you to look at the component definition to find the variable names. I hate this :). To solve this and make your code readable and concise in the proccess, define all member variables in the prototype object.

MyClass = function(){ }

Object.registerClass("MySymbol",MyClass);

MyClass.prototype.memberVar = "string";
MyClass.prototype.enabled = true;
MyClass.prototype.selectionType = "single";

Just a simple tip that a lot of people overlook. I always put member variables in the prototype, which is a good topic of debate. Many people prefer to define member variables in the constructor, which is required anyway for reference types. But any and all that I can define in the prototype object...I do.

This makes code more readable to me, as well as more straight forward to extend. The default will be there, this way I don't have to redefine these defaults before super is run, as well as call any methods that may go along with them (ie. setSelectionType(this.selectionType) )

PS I admit I had a few drinks before I wrote this, I appologize for glaring errors (such as spelling components wrong in the title)
11:35:28 PM    comment []


© Copyright 2003 Greg Burch.
 
December 2002
Sun Mon Tue Wed Thu Fri Sat
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        
Nov   Jan

Home

Articles
Live Previews
Common Component Issues
Flash Remoting
SharedObjects
FlashVars
Extending Components
__resolve and apply
XML 2 DataProvider

Macromedia WebLogs
Jeremy Allaire
mesh on mx
jd on mx
An Architect's View

Other WebLogs
Peter Hall
Eric Dolecki
Flash the Future
jdb cyberspace
Branden Hall
OnRelease
Josh Dura
moik78
Full As A Goog
Flash Magazine
Claus Wahlers
Arul Kumaran
Phillip Torrone
Quasimondo
Guy Watson
Robert Hall


Resources
Macromedia Mobile Development Center

Books
Flash Design for Mobile Devices

Flash Enabled

Click to see the XML version of this web page.

Click here to send an email to the editor of this weblog.