Always learning... :) "A type cast is NOT about changing the type at runtime."
I agree but the pattern of use for casting using Class( obj ) collides directly with global functions created for type conversion. If the following methods are used to upcast an object, these can wildly change the value and type at runtime. Array() http://livedocs.macromedia.com/labs/1/flex/langref/package.html#Array() Boolean() http://livedocs.macromedia.com/labs/1/flex/langref/package.html#Boolean() Number() http://livedocs.macromedia.com/labs/1/flex/langref/package.html#Number() String() http://livedocs.macromedia.com/labs/1/flex/langref/package.html#String() XML() http://livedocs.macromedia.com/labs/1/flex/langref/package.html#XML() XMLList() http://livedocs.macromedia.com/labs/1/flex/langref/package.html#XMLList() Here is a fun one: var myArrayCollection:ArrayCollection = new ArrayCollection(); myArrayCollection.addItem(1); myArrayCollection.addItem(2); myArrayCollection.addItem(3); var myArray:Array = Array( myArrayCollection ); //results in [ myArrayCollection ] not myArrayCollection cast as an Array. //warning suggests using "as" not Array( obj ), ok lets try that... var myArray:Array = myArrayCollection as Array; flash.util.trace( myArray ) //null ArrayCollection does not subclass Array, it uses Proxy so a perceived upcast of an ArrayCollection to an Array will result in a null value returned at runtime and no compiler warning. This seems like a real mess to me and will be the source of many threads of discussion and confusion. The Proxy class needs to have support added to handle "as" operators such that ArrayCollection can work seamlessly like so: flash_proxy override function asOperation( castClass:Object ):* { if( castClass == Array ) return this.source; return null; } I would actually love to see these confusing global functions removed and have a specific class created for type conversion say flash.util.Convert: flash.util.Convert.toString( Object ):String flash.util.Convert.toBoolean( Object ):Boolean flash.util.Convert.toArray( Object ):Array flash.util.Convert.toObject( Object ):Object flash.util.Convert.toNumber( Object ):Number flash.util.Convert.toUint( Object ):uint flash.util.Convert.toByteArray( Object ):ByteArray flash.util.Convert.toXML( Object ):XML flash.util.Convert.toXMLList( Object ):XMList flash.util.Convert.toXMLDocument( Object ):XMLDocument At least then casting (compiletime) and type conversion (runtime) would not have any overlap. Although this is easier said than done, removal of global functions bumps into an ECMA issue. Regards, ------------------------------------ Cynergy Systems, Inc. Theodore Patrick Sr. Consultant [EMAIL PROTECTED] tel: 1.866.CYNERGY http://www.cynergysystems.com -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.385 / Virus Database: 268.4.1/309 - Release Date: 4/11/2006 -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/flexcoders/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/

