Hello Benoit,

> Indeed, making all my VO classes dynamic solves the problem.
> Not very "clean", but excellent workaround ;).

that is so interesting that I've spend few minutes on that,
try another way which seems for me to not be a work around:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; xmlns="*">
        <mx:Script>
        <![CDATA[
                import mx.utils.UIDUtil;
                import mx.utils.ObjectProxy;
                import mx.controls.Alert;
            import mx.collections.*;
            [Bindable]
            public var collection:ArrayCollection;
           
            public function loadWithClassInstances():void {
                  var item1:ItemVO = new ItemVO();
                  item1.label = "Item 1 (class)";
                  var item2:ItemVO = new ItemVO();
                  item2.label = "Item 2 (class)";
                  var item3:ItemVO = new ItemVO();
                  item3.label = "Item 3 (class)";
                  collection = new ArrayCollection(
                                        [new ObjectProxy(item1, 
UIDUtil.createUID()),
                                        new ObjectProxy(item2, 
UIDUtil.createUID()), 
                                        new ObjectProxy(item3, 
UIDUtil.createUID())]);
            }
           
            public function loadWithObjects():void {
                  collection = new ArrayCollection([{label:"Item 1
(object)"},
                      {label:"Item 2 (object)"},
                      {label:"Item 3 (object)"}]);
            }
        ]]>
    </mx:Script>
        <mx:Button label="Load with class instances"
click="loadWithClassInstances()" />
        <mx:Button label="Load with objects" click="loadWithObjects()" />
        <mx:List id="list"      dataProvider="{collection}"
            rowCount="5" width="180" 
            click="Alert.show('ItemVO.label:
'+ItemVO(ObjectProxy(list.selectedItem).object_proxy::object).label);"/>
</mx:Application>

the only problem is additional coding is required when:
- data provider is build
- you are accessing proxied object and need to cast it to original
class (proxiedItem.object_proxy to ItemVO),
but that seems to work fine,

also if your other classes use "uid" you can consider adding custom public
namespace to your class for that property to avoid conflict
with IUID namespace,

kind regards,
Peter Blazejewicz





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