Actually Im gettin quite blur with the shared object concept. This is my AS
file.
*

package* {

*import* mx.collections.ArrayCollection;

*import* flash.net.SharedObject;

*public* *class* LSOHandler {

*private* *var* mySO:SharedObject;

*private* *var* ac:ArrayCollection;

*private* *var* lsoType:String;

*// The parameter is "feeds" or "sites".
*

*public* *function* LSOHandler(s:String) {

init(s);

}

*private* *function* init(s:String):*void* {

ac = *new* ArrayCollection();

lsoType = s;

mySO = SharedObject.getLocal(lsoType);

*// mySO.clear();
*

*if* (getObjects()) {

ac = getObjects();

}

}

*public* *function* getObjects():ArrayCollection {

*return* mySO.data[lsoType];

}

*public* *function* addObject(o:Object):*void* {

ac.addItem(o);

updateSharedObjects();

}

*private* *function* updateSharedObjects():*void* {

mySO.data[lsoType] = ac;

mySO.flush();

}

}

}
Hope you can help me.


On 2/28/09, Venkat Viswanathan <[email protected]> wrote:
>
> Hi,
>
> In this code, I can see that you are trying to get the data from shared
> objects (and u are getting null), but where are you saving it to shared
> object?
>
> Regards,
> Venkat
> www.venkatv.com
>
>
> On Fri, Feb 27, 2009 at 8:01 AM, mandy <[email protected]> wrote:
>
>>
>> Hi,
>>
>> I have develop an application in which I want to compare 2
>> arrayCollection after a refesh. That's why I use share Objects.
>> However, the arrayCollection failed to store as shared objects. May
>> anyone tell me which aprt went wrong? Below is my code:
>>    <mx:Script>
>>        <![CDATA[
>>        import mx.controls.Alert;
>>        import mx.collections.ArrayCollection;
>>        import mx.utils.ObjectUtil;
>>        import flash.net.SharedObject;
>>
>>        [Bindable]
>>        public var welcomeMessage:String;
>>
>>        [Bindable]
>>        public var localBus:ArrayCollection = new ArrayCollection();
>>
>>        [Bindable]
>>        public var localBus1:ArrayCollection = new ArrayCollection();
>>
>>       [Bindable]
>> public var orgData:ArrayCollection = new ArrayCollection();
>>
>>        public var lsofeeds:LSOHandler;
>>        public var lsosites:LSOHandler;
>>        public var lsobus:LSOHandler;
>>
>>        private var request:URLRequest = new URLRequest("http://
>> 192.168.0.1/HISuite/HI_MEC_rssDisplayLatestCloseROUpdates.php");
>>        private var loader:URLLoader = new URLLoader();
>>        private var XML_busList:XML;
>>
>>       private function onComplete(event:Event):void
>> {
>> try{
>>        var loader:URLLoader = event.target as URLLoader;
>>        if (loader != null)
>>        {
>>                XML_busList = new XML(loader.data);
>>                //trace(XML_busList.toXMLString());
>>
>>                var a:String = XML_busList.toXMLString();
>>
>>                               var arr:Array =new Array();
>>
>>                for each (var prop:XML in XML_busList.row)
>>                {
>>                        var obj:Object = new Object();
>>                arr.push(String(prop.attribute("wipbusno")));
>>                                                                obj.Bus =
>>  arr.shift();
>>
>>  orgData.addItem(obj);
>>                                                                }
>>        }
>>        }catch(e:TypeError){
>>                Alert.show("Error");
>>        }
>> }
>>
>>        public function aNotInB(avArrayA :ArrayCollection,
>> avArrayB :ArrayCollection):ArrayCollection
>> {
>>        var lvArray:ArrayCollection;
>>
>>        for each( var avObjectA:Object in avArrayA )
>>        {
>>                if( avArrayB.getItemIndex( avObjectA ) == - 1 )
>>                        lvArray.addItem( avObjectA );
>>        }
>>
>>        return lvArray;
>>
>> }
>>
>>        private function initApp():void {
>>                loader.load(this.request);
>>        loader.addEventListener(Event.COMPLETE, onComplete);
>>
>>        lsobus = new LSOHandler("wipbusno");
>>        localBus1 = lsobus.getObjects();
>>
>>                 trace(localBus1);
>>        ocalBus = aNotInB(orgData, localBus1);
>>
>>        for each( var avObjectA:Object in orgData )
>>        {
>>                trace("add bus 1");
>>                lsobus.addObject(avObjectA);
>>        }
>>
>>
>>                }
>>
>>             ]]>
>>    </mx:Script>
>>    <mx:DataGrid dataProvider="{localBus1}">
>>        <mx:columns>
>>            <mx:DataGridColumn headerText="Local Bus 1"
>> dataField="Bus"/>
>>        </mx:columns>
>>    </mx:DataGrid>
>>    <mx:DataGrid dataProvider="{orgData}">
>>        <mx:columns>
>>            <mx:DataGridColumn headerText="Bus" dataField="Bus"/>
>>        </mx:columns>
>>    </mx:DataGrid>
>>    <mx:DataGrid dataProvider="{localBus}">
>>        <mx:columns>
>>            <mx:DataGridColumn headerText="Local Bus" dataField="Bus"/
>> >
>>        </mx:columns>
>>    </mx:DataGrid>
>>
>> </mx:Application>
>>
>> The trace result shows that the shared objects is null and the string
>> "add bus 1" doesnt show.I know it may be the problem of how I handle
>> the shared object. Can anyone help?
>>
>> Thanks
>>
>>
>>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Flex 
India Community" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/flex_india?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to