Archive for the 'actionscript' Category


ThunderBolt :: Firefox Debugging Tool for Flex / AS3 / AS2

I usually use the built-in debugger in Flex Builder accompanied with FlashTracer (when I’m not running in debug mode and/or in prod depending on some query string params I toss in) to debug my Flex applications, but my buddy John pointed me to this new plugin for Firebug for FireFox called ThunderBolt; it provides the usual trace statements like FlashTracer with some additional features like a tree for complex objects and a memory snapshot. I don’t want to repeat what the site already says about it, so I’m just going to provide a link to get you there.
Since I’m on the topic of debugging I thought I’d also add in my other handy weapon of choice: ServiceCapture. It’s a simple HTTP proxy that catches all your data going across the wire (from flex to your server and back); the really cool part is that allows you to inspect your request and response objects of any of the following types: plan text, xml, web services, and AMF (the binary protocol used to perform Flash Remoting or Java-RPC in Flex).
I’m curious to hear people’s thoughts on this, so what are you using?

Getting Around Unknown Namepsaces in Flex/AS3

In my last post I presented a RegEx solution to remove a pesky namespace from an XML response payload; another possible solution is to use the * notation to specify any namespace like the following:
Any namespace
The following example shows how to get an element or attribute value when any namespace is specified on the element or attribute:
var attributes:XMLList = XML(event.result).*::Description.*::value;
The previous code returns xxx for either one of the following XML documents:
XML document one:
<rdf:RDF xmlns:rdf="">
XML document two:
<rdf:RDF xmlns:rdf="" xmlns:cm="">
I nabbed this chunk of code from the Flex Developer’s Guide, section “Handling results as XML with the e4x result format.

Remove Annoying XML Namespaces in Flex/AS3

My buddy pointed out another approach that I show here — it’s easier and doesn’t actually remove the namespace.
XML namespaces can be a real pain in the a$$ in AS3, so I often just rip them out. I mean think about it…when you get some XML payload back in a web service response, do you really care or need the namespace? Nah….just rip that bad boy out and starting using your XML baby.
Here’s my quick and dirty AS3 XML Namespace Ripper — for the sake of argument and a quick example, just assume this is in a Responder object like a Caringorm business delegate, but it should probably exist in a static XML util:
public function result(response:Object):void
var xmlString:String;
var xmlnsPattern:RegExp;
var namespaceRemovedXML:String;
var responseXML:XML;

// get the XML payload
if(ResultEvent(response).result is XMLList)
response = ResultEvent(response).result as XMLList;
response = ResultEvent(response).result as XML;

// convert it to a string
xmlString = response.toXMLString();

// define the regex pattern to remove the namespaces from the string
xmlnsPattern = new RegExp("xmlns[^\"]*\"[^\"]*\"", "gi");

// remove the namespaces from the string representation of the XML
namespaceRemovedXML = xmlString.replace(xmlnsPattern, "");

// set the string rep. of the XML back to real XML
responseXML = new XML(namespaceRemovedXML);

// do something with the XML
Thanks for the quick refresher on regex Johnny!