I am writing an app for the Blackberry Playbook using Flash Builder 4.6 and flex. I have run into an issue which I am hoping someone may be able to assist me with. It is as follows:
First off, I am making an app that allows a user to browse through various reddit feeds. I am making use of the reddit API, in which you are able to use either JSON or XML formatted data. I am using XML. Within Adobe Flash Builder I have run the ‘Data/Services’ wizard to connect to the data source which pulls in the latest 25 or so entries on Reddit. Then I bound that data to a spark List component which is housed in the view, ‘redditFeed’. You will notice that it uses AsyncListView. This is the code:
redditFeed.mxml
<fx:Script>
<![CDATA[
public function myList_creationCompleteHandler():void
{
getRedditFeedResult.token = redditFeedGrabber.getRedditFeed("");
}
]]>
</fx:Script>
<fx:Declarations>
<s:CallResponder id="getRedditFeedResult"/>
<redditfeedgrabber:RedditFeedGrabber id="redditFeedGrabber"/>
<s:CallResponder id="redditFeedJSONResult"/>
</fx:Declarations>
<s:List id="feedList" width="100%" height="100%" change="myList_changeHandler(event)"
contentBackgroundColor="#deefff"
creationComplete="myList_creationCompleteHandler()">
<s:AsyncListView id="asyncList" list="{getRedditFeedResult.lastResult}"/>
<s:itemRenderer>
<fx:Component>
<s:IconItemRenderer iconField="thumbnail"
iconWidth="64" iconHeight="64"
labelField="title" fontSize="20"
messageField="pubDate"
verticalAlign="top"
iconPlaceholder="{assets.LoadingIcon}">
<fx:Script>
<![CDATA[
import assets.LoadingIcon;
]]>
</fx:Script>
</s:IconItemRenderer>
</fx:Component>
</s:itemRenderer>
</s:List>
Now for my problem; I have a refresh button named ‘refreshButton’. I would like for the data in the spark List above to be refreshed when a user clicks this button. I have searched far and wide for a solution, to no avail.
So, how am I able to reload the xml data that is bound to the list, and then have the list show this new data?
I appreciate any help you can provide. Please let me know if there is anything more I can provide to help you in assisting me. Thanks!
All you should have to do is make the same call that’s made in the creation complete handler in your button click handler. Setting the token and making the call again should force a refresh when the ASyncToken gets a result.