I have an old app which allows the user to drag items between two tilelists and 
then save the contents of both tilelists by clicking a save button using the 
sharedObject method. The tilelists are populated by array collections defined 
in the app. I want to change this so that the tilelists are instead populated 
by an array collection which I've retrieved from a remote xml file via http 
request but I can't get this to work. Basically I need to replace both the 
predefined array collections profile1NewsAndSportaddLinksFullAC and 
profile1NewsAndSportaddLinksAC with my xml/httprequest produced newsAC array 
collection and still make the tilelists saveable. Can anyone help me out? 
Here's the code:-

<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication

 xmlns:mx="http://www.adobe.com/2006/mxml"; layout="absolute" 
creationComplete="newsService.send(); initprofile1NewsAndSportSO()">

<mx:Script>
<![CDATA[


import mx.rpc.events.ResultEvent;

import mx.collections.*;

import flash.net.SharedObject;
[

Bindable]

private var newsAC:ArrayCollection;


private function newsResultHandler(event:ResultEvent):void{
newsAC=newsService.lastResult.newscategory.news;
}


public var profile1NewsAndSportSO:SharedObject;

private var profile1NewsAndSportaddLinksFullAC:ArrayCollection = new 
ArrayCollection([{label:

BBC News},{label:

ITV},{label:

Sky News}]);



private var profile1NewsAndSportaddLinksAC:ArrayCollection = new 
ArrayCollection([{label:

BBC News},{label:

ITV},{label:

Sky News}]);



private function profile1NewsAndSportReset():void{resetprofile1NewsAndSportAC();
profile1NewsAndSportAddLinksTilelist.dataProvider 
= profile1NewsAndSportaddLinksAC;
profile1NewsAndSportLinkChoice.dataProvider = 

new ArrayCollection([]); }



private function 
resetprofile1NewsAndSportAC():void{profile1NewsAndSportaddLinksAC.removeAll();


for each(var obj:Object in 
profile1NewsAndSportaddLinksFullAC){profile1NewsAndSportaddLinksAC.addItem(obj);
}
}



private function initprofile1NewsAndSportSO():void{profile1NewsAndSportSO = 
SharedObject.getLocal(

profile1NewsAndSport);

if(profile1NewsAndSportSO.size > 0){

if(profile1NewsAndSportSO.data.profile1NewsAndSportaddList){

if(profile1NewsAndSportSO.data.profile1NewsAndSportaddList != empty){

var profile1NewsAndSportaddList:Array = 
profile1NewsAndSportSO.data.profile1NewsAndSportaddList.split(,);

var profile1NewsAndSporttempAC1:ArrayCollection = new ArrayCollection();

for each(var str:String in profile1NewsAndSportaddList){

for each(var obj1:Object in profile1NewsAndSportaddLinksAC){

if(str == obj1.label){profile1NewsAndSporttempAC1.addItem(obj1);


continue;}
}
}


if(profile1NewsAndSporttempAC1.length > 
0){profile1NewsAndSportAddLinksTilelist.dataProvider = 
profile1NewsAndSporttempAC1;
} 
}
}


if(profile1NewsAndSportSO.data.profile1NewsAndSportchoiceList){

var profile1NewsAndSportchoiceList:Array = 
profile1NewsAndSportSO.data.profile1NewsAndSportchoiceList.split(,);

var profile1NewsAndSporttempAC2:ArrayCollection = new ArrayCollection();

for each(var str2:String in profile1NewsAndSportchoiceList){

for each(var obj2:Object in profile1NewsAndSportaddLinksAC){

if(str2 == obj2.label){profile1NewsAndSporttempAC2.addItem(obj2);


continue;}
}
}


if(profile1NewsAndSporttempAC2.length > 
0){profile1NewsAndSportLinkChoice.dataProvider = profile1NewsAndSporttempAC2;
} 
}
}

else{profile1NewsAndSportReset();
}
}


private function saveprofile1NewsAndSport(event:MouseEvent):void{

var profile1NewsAndSportaddList:String = ;

if(profile1NewsAndSportAddLinksTilelist.dataProvider){

if(ArrayCollection(profile1NewsAndSportAddLinksTilelist.dataProvider).length > 
0){

for each(var obj1:Object in profile1NewsAndSportAddLinksTilelist.dataProvider){
profile1NewsAndSportaddList += obj1.label + 

,;}
}

else{profile1NewsAndSportaddList = 

empty;}
}
profile1NewsAndSportSO.data.profile1NewsAndSportaddList = 
profile1NewsAndSportaddList; 


var profile1NewsAndSportchoiceList:String = ;

for each(var obj2:Object in profile1NewsAndSportLinkChoice.dataProvider){
profile1NewsAndSportchoiceList += obj2.label + 

,;}
profile1NewsAndSportSO.data.profile1NewsAndSportchoiceList = 
profile1NewsAndSportchoiceList;
profile1NewsAndSportSO.flush();
}
]]>


</mx:Script>


<mx:HTTPService id="newsService" resultFormat="object" 
result="newsResultHandler(event)" 
url="http://www.coolvisiontest.com/getnews.php"/> 


<mx:Button click="profile1NewsAndSportReset()" id="reset" label="

Reset" y="5" height="25" x="5"/>


<mx:TileList id="profile1NewsAndSportLinkChoice" fontWeight="bold" dragEnabled="

true" dragMoveEnabled="true" dropEnabled="true" height="129" width="

650" top="5" left="521" columnCount="5" rowHeight="145" columnWidth="

125" backgroundColor="#000000" color="#FFFFFF"/>


<mx:TileList id="profile1NewsAndSportAddLinksTilelist" fontWeight="bold" 
dragEnabled="

true" dragMoveEnabled="true" dropEnabled="true" height="129" width="

385" top="5" left="128" columnCount="3" rowHeight="145" columnWidth="125" 
backgroundColor="

#000000" color="#FFFFFF"/>


<mx:Button click="saveprofile1NewsAndSport(event)" id="save" label="Save 
Changes" x="

5" y="38" width="113" height="25.5"/>

</mx:WindowedApplication>


Reply via email to