E4X – Updating multiple node values
Something that is often required when processing XML documents is to update a bunch of nodes that are spread throughout the document.
Consider the following XML:
<gallery base="images/projects/"> <project id="1" > <item type="image" thumb="image1.jpg"> <path>l_image1.jpg</path> </item> </project> <project id="2"> <item type="image" thumb="image2.jpg"> <path>l_image2.jpg</path> </item> </project> <project id="3"> <item type="image" thumb="image1.jpg"> <path>l_image1.jpg</path> </item> <item type="image" thumb="image3.jpg"> <path>l_image3.jpg</path> </item> <item type="image" thumb="image4.jpg"> <path>l_image4.jpg</path> </item> <item type="image" thumb="image5.jpg"> <path>l_image5.jpg</path> </item> </project> </gallery>
Lets assume that we need to load the thumbnails of each item specified by the thumb attribute. I often use a base path for the images. It make a lot of sense to include it at document level rather than repeating it in each property value. Doing so reduces file size and also makes path updates quick and painless.
Once the XML document is loaded, the thumb path can be updated with a single line of code:
galleryXML..item.(@thumb = baseUrl + @thumb);
where baseUrl variable holds the base path. Or we can directly substitute with the value of base property like so:
galleryXML..item.(@thumb = galleryXML.@base.toString() + @thumb);
A trace of galleryXML will show that the path of each thumb attribute is prefixed with the base path.
Offline language reference in Flash CS4
If, like me, you’re frustrated with CS4 language reference going to the online version, there is a part solution available which Jon has written about a while back. Basically what it does is instead of going online, it opens the local copy of help inside the browser – which is much faster for quick look-ups.
To do this; from the top menu, open Window > Extensions > Connections. Then click on the down arrow at top right of the panel and select “Offline options“.
I hope Adobe will provide a help panel similar to Flex builder in the upcoming version…
Open Flash Chart
Great collection of fully customisable Flash (8) based charting components.
Gradient Tween Editor
Handy tool with which to interactively compose a gradient and get the Flash code.
Image processing library
This is one excellent library, done by Joa Ebert!
The Imageprocessing Library is a set of ActionScript 3 classes designed to work simple and performant. It comes with more than 50 filters to manipulate images and synthesize textures.
Also has excellent documentation!
Flash CS3 IDE bug
This is a real weird one; for a while now, when I quit the IDE the whole thing would freez up and the only way to close it would be to end the process. Try as I might, repare, reinstall, nothing fixed the issue.
Then recently, almost by chance, I came aross a post which had the following comment:
Dragging in 3D – The Right Way
Real cool example of dragging in 3D
SWFObject 2 and SWFAddress
There seems to be an issue when using SWFObject 2 with SWFAddress; If a movie id is not specified through the optional “attributes” param in the embedSWF method -
swfobject.embedSWF( “main.swf”, “flashcontent”, “700″, “400″, “9″ )
, SWFAddress fails to initialise and generates an error:
B8? is undefined
G()()
swfaddress.js (line 8 ) index2.html()() (line 38) on this error?
if(typeof com==”undefined”){var com={}}i…E]==”id”){SWFAddress.addId(B[E+1])}}}}};
Once I changed it to the following, it worked perfectly:
swfobject.embedSWF( “main.swf”, “flashcontent”, “700″, “400″, “9″, null, {}, {}, {id: ‘main’} );
The docs for SWFAddress doesn’t specify that the ID attribute is required either. I spent a few hours trying to figure out what I was doing wrong so hopefully this will help someone else to not do the same.
Google maps in Flash CS3
With the recent release of Google maps API for Flash, I was looking forward to giving it a run, BUT – the SWC that is available for download doesn’t seem to work with Flash CS3, only with Flex!
Flex is awesomeness alright, but if building a very stylized interface I find Flash much easier to deal with. I am just about to start on such a project and was disappointed to find that it didn’t work in Flash.
After doing some searching I came across this issue thread over at Google. Vincent has kindly shared a SWC that’s compatible with CS3, which works a treat!!
While this is excellent, I still hope that Google releases a official SWC for CS3 sometime soon…
Here’s first attempt at it! (Source)
Flash Particle Effects
Another nice Flash Particle Effects engine – FLINT
