The array is just handling objects, so you lose the protection that having known classes gives you.

There are occassions when having dynamic classes is essential, but they must be rare. I think too many developers just try and emulate the bad habits of AS1 and AS2 to get around learning the good habits of AS3 ( explicit classes, inheritance, etc.).

Dynamically adding attributes like this makes you open to runtime failure, something that extending classes helps to protect you from.

I know - I get tempted by the dark side myself..

Paul
----- Original Message ----- From: "Cor" <c...@chello.nl>
To: "'Flash Coders List'" <flashcoders@chattyfig.figleaf.com>
Sent: Sunday, January 25, 2009 1:44 PM
Subject: RE: [Flashcoders] Adding a property to an AS3-component


About the array, that works fine!!
When you are into classes, that is preferable!

If you want an example of how I do it with an array, let me know.

HTH
Cor

-----Original Message-----
From: flashcoders-boun...@chattyfig.figleaf.com
[mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of jonathan
howe
Sent: zondag 25 januari 2009 14:33
To: Flash Coders List
Subject: Re: [Flashcoders] Adding a property to an AS3-component

Seems like Cor's Array solution would make it through the compiler but would still throw a runtime error, right? I would much more strongly recommend the
extending solution that Dave suggests.

On Sat, Jan 24, 2009 at 12:14 PM, Dave Watts <dwa...@figleaf.com> wrote:

> is it actually possible to add a new property
> to an AS3-component, like button?

In AS3, classes will only allow this if they're dynamic classes, and
most classes aren't dynamic. You could, however, write a new class to
extend Button.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/

Fig Leaf Software provides the highest caliber vendor-authorized
instruction at our training centers in Washington DC, Atlanta,
Chicago, Baltimore, Northern Virginia, or on-site at your location.
Visit http://training.figleaf.com/ for more information!
 _______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders




--
-jonathan howe
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
No virus found in this incoming message.
Checked by AVG - http://www.avg.com
Version: 8.0.176 / Virus Database: 270.10.13/1914 - Release Date: 24-1-2009
20:40

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to