Main Project: Start with flex
Then 2009 started and we have begun our main project (bachelor thesis). We ended up with an exciting project that has been provided by Brook Consulting. The project has been named AirDog .
Essentially this project is on developing a reporting and statistical software to data supplied by the Norwegian Kennel Club (NKK).
The two supervisors that we have been awarded by the Brook called Erlend and Ole. They are members of gundog clubs Pointer and Breton, then the program will mainly be directed at these two clubs in the first place.
We shall use the languages flex and php. We have some experience with php before, but flex is something completely new.
After some experimentation I ended up with this:

Feed Flex states and one can say that I missed a bit, but learned a lot. To subscribe to a feed with Feed Flex, you need a crossdomain.xml in the root of the domain from the feed comes from. It also needs to be set up so that one can access from the outside.
The reason I did not notice this before the program was "finished" was that in debug mode there is no requirement for crossdomain.xml introduced. It was only when I sent the application to Tore (school friend) that I noticed that something was wrong. For those who want to access files and information outside the domain as your Flex app is running so read more about here: Flash / Flex Tutorial - How to Create a crossdomain.xml file.
The source code for Flex Feed:
FeedFlex.mxml
<?xml version="1.0"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" initialize="initData()" width="100%" height="100%"> </mx><mx :Script> < ![CDATA[ import mx.rpc.events.FaultEvent; import mx.formatters.DateFormatter; import mx.resources.ResourceBundle; import mx.collections.*; import mx.controls.*; import mx.events.*; [Bindable] public var localFeeds:ArrayCollection = new ArrayCollection(); public var lsofeeds:LSOHandler; public function initData():void { lsofeeds = new LSOHandler("feeds"); if (lsofeeds.getObjects()) { localFeeds = lsofeeds.getObjects(); } } private function addFeed():void { var df:DateFormatter = new DateFormatter(); df.formatString="DD-MMM-YYYY"; var o:Object = {name:addAName.text, url:addAurl.text, date:df.format(new Date())}; lsofeeds.addObject(o); localFeeds = lsofeeds.getObjects(); addAName.text = ""; addAurl.text = ""; } private function removeFeed(eventObj:CloseEvent):void { if (eventObj.detail==Alert.OK) { if (myGrid.selectedIndex > -1) { localFeeds.removeItemAt(myGrid.selectedIndex); } } } public function clickHandler(event:ItemClickEvent):void { if (event.index == 0){ httpRSS.url = myGrid.selectedItem.url; httpRSS.send(); } else if (event.index == 1) { myGrid.editable = true; } else { var objAlert:Alert = Alert.show( "Vil du slette " + myGrid.selectedItem.url, "Slette?", Alert.OK | Alert.CANCEL, this, removeFeed, null, Alert.OK); } } private function feedFaultHandler(event:FaultEvent):void { Alert.show("Problem med å laste inn feeden\n" + "Problemet kan komme av at det ikke er en feed url som er skrevet inn.", "Feed problem"); } ]]> </mx> <mx :HTTPService id="httpRSS" resultFormat="object" fault="feedFaultHandler(event);" /> <mx :VBox id="theBox" height="100%" width="80%" horizontalAlign="center"> </mx><mx :Panel id="adder" title="RSS URL" width="100%"> </mx><mx :Form width="100%"> </mx><mx :Canvas height="57"> <mx :Label id="labelUrl" text="URL:" x="0" y="29"/> <mx :Label id="labelNavn" text="NAVN:" x="0" y="1"/> <mx :TextInput id="addAName" width="287" borderStyle="solid" x="46" y="0"/> <mx :TextInput id="addAurl" width="287" borderStyle="solid" x="46" y="25"/> <mx :Button label="Legg til" click="addFeed()" x="341" y="25"/> </mx> <mx :DataGrid id="myGrid" width="100%" height="133" dataProvider="{localFeeds}"> </mx><mx :columns> <mx :DataGridColumn headerText="Navn" dataField="name" /> <mx :DataGridColumn headerText="Url" dataField="url" /> <mx :DataGridColumn headerText="Dato lagt inn" dataField="date" /> </mx><mx :DataGridColumn headerText="Slett" editable="false"> </mx><mx :itemRenderer> </mx><mx :Component> </mx><mx :ButtonBar itemClick="outerDocument.clickHandler(event)"> </mx><mx :dataProvider> </mx><mx :Array> </mx><mx :String>Last inn</mx> <mx :String>Rediger</mx> <mx :String>Slett</mx> <mx :Panel id="reader" title="RSS innhold" width="100%"> </mx><mx :DataGrid id="entries" width="100%" dataProvider="{httpRSS.lastResult.rss.channel.item}" itemClick="{body.htmlText=httpRSS.lastResult.rss.channel.item[entries.selectedIndex].description}"> </mx><mx :columns> <mx :DataGridColumn dataField="title" headerText="Tittel" /> <mx :DataGridColumn dataField="pubDate" headerText="Dato" /> </mx> <mx :TextArea id="body" editable="false" width="100%" height="100"/> LSOHandler.as
// ActionScript 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; public function LSOHandler(s:String) { init(s); } private function init(s:String):void { ac = new ArrayCollection(); lsoType = s; mySO = SharedObject.getLocal(lsoType); 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(); } } } Used Adobe - Flex 3 LiveDocs to find most of the information you need to get started.
It helped in particular to understand the Shared Object, which is the Flex's kind of cookie. For more information about how you use it you can check out this link: http://livedocs.adobe.com/flex/3/html/help.html?content=lsos_3.html
Check out our project page http://prosjekt.mindre.net


