Sample App : MXNA Stand-alone viewer

I recently moved moved offices, and am now sitting with the Flash team. One thing I noticed was that we have a nice 42″ Plasma screens, which was not being used. So, I decided to put together a simple application that would make it easy to help keep myself and the Flash team up with the latest news and information from the Flash community.

The application I created, MXNA Feed Scroller (original name, heh?), is a Flash based, fullscreen standalone application that displays information on the last 15 weblog posts from the Flash community. It is updated every 15 minutes. It gets its information from the MXNA web service API and uses the MXNA ActionScript 2 Library.

Here is a picture of the app in action:


Here is a screen shot of the app:


You can download the source code for the application from here.

And just because I like to look at the output from Sean Voisen’s Code Beautifier so much, here are the two classes for the application:

[code]import com.macromedia.mxna.MXNAWebService;import;/* Associated with the main app controller clip */class extends MovieClip{private var mxna:MXNAWebService;private var feedView:MXNAFeedView;private var category:String = “Flash”;private var interval:Number = (60 * 15 * 1000); // 15 minutes/*Constructor. We do everything in onLoad to be sureeverything has initialized*/public function MXNAFeedScrollerController(){}/*Called by Flash when the clip is laoded on stage. We do a bunch ofinitialization here.*/private function onLoad():Void{Mouse.hide();mxna = new MXNAWebService();mxna.addEventListener(“onGetPostsByCategory”, this);//load the posts from the serverloadPosts();//reloads the posts from the server at the specified intervalsetInterval(this, “loadPosts”, interval);}/*Loads the latests posts from the server*/private function loadPosts(Void):Void{mxna.getPostsByCategory(category);}/*called when posts are loaded from the server*/private function onGetPostsByCategory(eventObj:Object):Void{feedView.setDataProvider(eventObj.posts);}}[/code]

[code]/* Associated with the feedview clip */class extends MovieClip{private var dp:Array;private var index:Number = 0;private var rankingClip:MovieClip;private var titleField:TextField;private var sourceField:TextField;private var postTimeField:TextField;private var contentField:TextField;private var urlField:TextField;/*How often (in milliseconds) the post is changed*/private var interval:Number = (15 * 1000); //15 seconds/*Constructor. We do everything in onLoad to be sureeverything has initialized*/public function MXNAFeedView(){}/*Called by Flash when the clip is laoded on stage. We do a bunch ofinitialization here.*/private function onLoad():Void{this.titleField.wordWrap = true;this.sourceField.wordWrap = true;this.postTimeField.wordWrap = true;this.contentField.wordWrap = true;this.urlField.wordWrap = true;setInterval(this, “rotatePost”, interval);}/* Displays the next post */private function rotatePost(){var tempIndex:Number = getNextIndex();populateFields(dp[tempIndex]);}/*returns the index for the next post.*/private function getNextIndex(){//if index is greater than or equal to the dp length//then we are at the last item. reset to the first itemif(index == (dp.length – 1)){index = 0;}else{index++;}return index;}/* specifies the dataprovider / array of posts */public function setDataProvider(dp:Array):Void{var isFirstLoad:Boolean = (this.dp == null);this.dp = dp;this.index = 0;if(isFirstLoad){populateFields(dp[0]);}}/*populates the posts from a given object (from the postdataprovider)*/private function populateFields(data:Object):Void{var star:Number = Number(data.ranking);if(star < 1){star = 1;}rankingClip.attachMovie("star" + star, "star", 999);this.titleField.text = data.title;this.sourceField.text =;this.postTimeField.text = data.dateAggregated;this.contentField.text = data.excerpt;this.urlField.text =;}}[/code]

Thanks to Josh Dura who cleaned up the look of the app for me.

if you find any bugs or have any questions or suggestions, post them in the comments.

3 Responses to Sample App : MXNA Stand-alone viewer

  1. Vesa says:

    That’s the way how I want to see latest news ;)I didn’t give deeper look for those scripts yet but they are looking good too.

  2. Peter says:

    Great stuff Mike, I think I’ll turn that baby into a screensaver 🙂

  3. Rob says:

    I can’t believe you guys had a 42″ plasma screen just laying around. I wanna work at Macromedia!