Posts in category flex

Robotlegs Fork: Getting Maven with It

I recently forked Robotlegs (on github) because I wanted to be able to build Robotlegs using Maven. Currently, Robotlegs uses Ant to build, test, generate asdoc's, etc. However, in my day-to-day projects I'm using Maven...in fact I don't even have Ant setup (which only takes 30 seconds once you download the ZIP).

In the next few days I expect to be done configuring the pom.xml at which point I'll submit a "pull request". This will allow one of the main people behind Robotlegs to decide if they want to pull it into the main Robotlegs source tree.

Loading an XML File with URLLoader when HTTPService Doesn't Work

I was trying to load an XML file that lives next to my SWF on a webserver that I run locally.

Example URLs:

I was trying to use HTTPService but I kept getting "URL must be specified with useProxy set to false". Even if I configured my HTTPService.useProxy = false I still got the same error.

I looked around for a resolution but nothing seemed to work, until I stumbled upon the URLLoader. I setup a URLLoader and requested my data, but when I received the Event.COMPLETE event the "event.target.data" property only showed the first line of my XML...I was expecting to cast the "data" to an XML object, but that gave me a null.

A blog post shed some light. Essentially you have to explicitly create a new XML object. Here's a short snippet, keep in mind this snippet only listens for the "COMPLETE" event, in reality you should also listen for the SecurityErrorEvent and IOErrorEvent.

public function getData():void {
  var loader:URLLoader = new URLLoader( new URLRequest('http://localhost/myapp/foo-config.xml' ));
  loader.addEventListener(Event.COMPLETE, onComplete);
}

public function onComplete(event:Event):void {
  // var data:XML = event.target.data as XML;  <--- doesn't work
  var data:XML = new XML(event.target.data);
}

Enjoy!

  • Posted: 2010-01-14 19:30 (Updated: 2010-01-14 19:30)
  • Author: craig
  • Categories: flex
  • Comments

Flex Goodies

On the main wiki page there is a link to the FlexStuff page which provides various Flex goodies that I've come across while developing with Flex.

blog comments powered by Disqus