Geoffrey,

This is a common misconception about return types. In the Flex docs, the type 
specified is the lowest subclass supported for the returned data. If the return 
type is Object, this can include Array, Boolean, String, Number, components, 
and most custom classes. 

But alas that is not the issue here, Houston we have a bug!

The error thrown by Flex without the cast is a bug in either ArrayCollection or 
DataGrid as value returned by the GETTER in selectedIndex should use the 
valueOf() method and it seems not to.

Change this:

objTemp = dg.selectedItem; //will throw an error about type coercion

To:

objTemp = dg.selectedItem.valueOf(); //Returns a ResourceVO correctly no cast, 
no error.

There is at handy new operator "is" in AS3 that is very useful for testing the 
inheiritance chain at runtime:

var mySprite:Sprite = new Sprite();
trace (mySprite is Sprite);                   // output: true
trace (mySprite is DisplayObject);            // output: true
trace (mySprite is IEventDispatcher);         // output: true 

I added this when the selectRow method is called and it is always true.

flash.util.trace( dg.selectedItem is ResourceVO ) //true

I believe that within the "is" operator, valueOf() is called automagically. :)

Hope this helps,

Ted :)

-- 
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/
 



Reply via email to