AS3, XML, CDATA – <strong> instead of <b>
With a recent Flash project, I was struggling to find a solution to display bolded HTML text from XML files that uses the <strong> tag. The reason I wanted to use <strong> instead of <b> was because the XMLs were being generated from MODx content management system. Since Flash cannot read the <strong> tag, I used the RegExp class in AS3 to find and replace <b> with <strong> in the XML content text before sending it to my htmlText in Flash to read. Below is the snippet of code is used:
var myPattern:RegExp = /strong/g;
var str:String = xml.content.toString();
contentTxt.htmlText = str.replace(myPattern, "b");
Though a simple solution, took me awhile a bit of research to arrive at the above conclusion. Therefore hope this saves some time for others!
AS3 – XML Gallery & Vertical Array
Finally had a moment to wrap up an ActionScript 3.0 learning project started the other week, in which I built a simple photo gallery in Flash. Each colored button loads a corresponding XML, which in turn arrays thumbnails that link to the full images. My focus was to most importantly refine my AS3 and XML skills, as well as working on clearing an XML array or image to load a new in place (NOT on top). Therefore, the buttons are manually created and placed, and I used simple tweening for their movements. They aren’t as smooth or consistent as I would have hoped, but I will be working on my understanding of AS3 tweening and creating function that define relationships between objects (with buttons for example). Also, in future iterations, the buttons themselves should be created and loaded based on an XML file. As you might guess, my end goal is moving towards being able to build an entire AS3 site from an XML database that can be edited via MySQL and PHP (working on the latter end with Howard over at crtl-i.com). I am able to build a full AS2 site based completely on an XML database with out the MySQL backend (example: secondstreetgallery.org), but really think its important to make the full AS3 jump.
