> So how come you don't sub class Array and add an 'on added' event that
tells the Player when something is added?
 
One reason is that there is no way that even a subclass of Array could
know when children[i] was assigned a new value. (EcmaScript and
ActionScript have ino equivalent of a setter function for array
elements.) And, of course, there would still be no type safety.
 
Another reason is that Arrays can be sparse -- you can have an Array
with elements 0, 1, 17, and 99. The Flash Player team didn't want this
model for the children of a DisplayObjectContainer.

> Who cares if Array isn't strongly typed? So long as the Player finds
> something that looks and smells like a DisplayObject, wouldn't that be
enough?
 
Most people who are writing nontrival apps come to rely heavily on type
safety as the single most important thing that the compiler provides. It
catches a huge number of bugs when you're writing your app rather than
leaving them for your customers to find at runtime.
 
Gordon Smith
Adobe Flex SDK Team

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of kjorn
Sent: Tuesday, February 26, 2008 1:20 AM
To: [email protected]
Subject: [flexcoders] Re: Sprite.children



--- In [email protected] <mailto:flexcoders%40yahoogroups.com>
, "Gordon Smith" <[EMAIL PROTECTED]> wrote:
>
> Are you asking "Why doesn't Sprite have a 'children' Array rather than
a
> numChildren property and a getChildAt() method?". The answer to that
is
> that AS3 lacks strongly typed Arrays, and lacks a way to know when
> you've modified an Array. For example, if you pushed a Sprite onto the
> Array, the Player wouldn't know to add it to the display list.
> 
> Gordon Smith
> Adobe Flex SDK Team
> 

Oh, OK. That is a bit annoying though.

So how come you don't sub class Array and add an 'on added' event that
tells the Player when something is added?

Who cares if Array isn't strongly typed? So long as the Player finds
something that looks and smells like a DisplayObject, wouldn't that be
enough?

Cheers,

monk.e.boy



 

Reply via email to