What is Flashdevelop and why should I care? FlashDevelop is an opensource integrated development environment (IDE). It was created using C# on the .net 2.0 so it runs on any windows box that has .net 2.0 or higher and Java 1.6 runtime. .Net 2.0 and Java 1.6 are already on most windows computers. The user also needs to have the Flex SDK to install FlashDevelop IDE properly. You can use this IDE to write action script 2/3, flex MXML, and HAXE. You can actually pick from several compilers. It is a wonderful open source program and if in the right hands can be utilized to write ActionScript quickly.
The people of Adobe have all been working hard on improving the features of ActionScript and they have a lots of open source libraries that allow developers to rapidly create highly functioning and quick rich internet applications (RIA). This example is only a beginner example note this is just suposed to be informative and quick. In regards to use the FlashDevelop IDE and it is based off of Mike Chambers example.
Step 1: Install the FlashDevelop IDE from their site here. Also make sure you follow the requirements found here.
Step 2: install the Flex SDK here.
Step 3: Insert the Flex SDK location here by selecting Tools from the drop down then go to Program Settings navigate to the AS3 Context panel and insert your Flex SDK location as shown below (click to enlarge):
Step 4: Create a new ActionScript 3 Flex 3 project name it and then hit OK as shown below:
Step 5: Minimize your FlashDevelop IDE. For this you will also have to download and install 2 ActionScript libraries written by the Adobe Developers and located on Google Code here: CoreLib , XMLsyndication Lib. Download the code extract and place the code on your computer. You will need the path so do not place it in a temporary location place it ether in its actual program directory or a place of your own choice. Once you have done that open FlashDevelop again. To your new Flex 3 project. Navigate to tools and drop down to Global Class paths. Place the paths to the code you just download and installed in the dialog window as shown below:
Step 6: Navigate to the SWC files right click on them and select add to library as shown below:
Step 7: Once you have done that you need to create your RSSExample.mxml document. To do this right click on your project drop down to add, select the new .MXML file name it RSSExample.mxml. Then right click on the project again add new ActionScript class name it RSSExampleClass.as.
Step 8: Now Place this code into the RSSExample.mxml file:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script source="RSSExampleClass.as" />
<mx:TextArea left="20" top="10" bottom="40" right="10" id="outputField"/>
<mx:Button label="Load RSS" right="10" bottom="10" click="onLoadPress()"/>
</mx:Application>
Step 9: Now Place this code into the RSSExampleClass.as file:
import com.adobe.utils.XMLUtil;
import com.adobe.xml.syndication.rss.Item20;
import com.adobe.xml.syndication.rss.RSS20;
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.events.SecurityErrorEvent;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.net.URLRequestMethod;
private var loader:URLLoader;
//url of rss 2.0 feed
private static const RSS_URL:String = "http://i-create.org/node/feed";
//called when user presses the button to load feed
private function onLoadPress():void
{
loader = new URLLoader();
//request pointing to feed
var request:URLRequest = new URLRequest(RSS_URL);
request.method = URLRequestMethod.GET;
//listen for when the data loads
loader.addEventListener(Event.COMPLETE, onDataLoad);
//listen for error events
loader.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityError);
//load the feed data
loader.load(request);
}
//called once the data has loaded from the feed
private function onDataLoad(e:Event):void
{
//get the raw string data from the feed
var rawRSS:String = URLLoader(e.target).data;
//parse it as RSS
parseRSS(rawRSS);
}
//parses RSS 2.0 feed and prints out the feed titles into
//the text area
private function parseRSS(data:String):void
{
//XMLSyndicationLibrary does not validate that the data contains valid
//XML, so you need to validate that the data is valid XML.
//We use the XMLUtil.isValidXML API from the corelib library.
if(!XMLUtil.isValidXML(data))
{
writeOutput("Feed does not contain valid XML.");
return;
}
//create RSS20 instance
var rss:RSS20 = new RSS20();
//parse the raw rss data
rss.parse(data);
//get all of the items within the feed
var items:Array = rss.items;
//loop through each item in the feed
for each(var item:Item20 in items)
{
//print out the title of each item
writeOutput(item.title);
}
}
private function writeOutput(data:String):void
{
outputField.text += data + "\n";
}
private function onIOError(e:IOErrorEvent):void
{
writeOutput("IOError : " + e.text);
}
private function onSecurityError(e:SecurityErrorEvent):void
{
writeOutput("SecurityError : " + e.text);
}
Step 10: Now run a test as show below:
Step 11: If successful should look like below:
Wow now that was cool. Now think about what you can do with that tool their lots of open source libraries to play with so get started. One thing I would like to do is play with the source and see if it could be ported to the Mono platform and make it run on Linux or Windows. Any way hope you had fun.
Recent Comments