Archive for March 2008

E4X delete… not so obvious… but easy

I’ve just been trying to delete a node and all its descendants from an XML object selected on the value of an attribute. Having read the “ECMAScript for XML (E4X) Specification” (PDF) as linked to from the Flex documentation I expected to be able to write the following…

delete theXMLObject..*.(@id=="theIDtoDelete");

however the above code will generate the following Flash Player runtime error…

TypeError: Error #1119: Delete operator is not supported with operand of type XMLList

The solution is simple if not obvious. The above code should be rewritten to ensure a single node is returned rather than a list…

delete theXMLObject..*.(@id=="theIDtoDelete")[0];

Distilled from this actionscript.org thread.

finding documentation on implementing native menus in Flex/AIR applications

When you come to build your first Flex/AIR application that needs a native menu (Application menu on a Mac, or Window menu on a Windows PC), you’ll probably find your way to the “Windows, menus, and taskbars” section within the documentation. From there you’ll navigate to “Working with native menus” and spend some time studying “Creating native menus” before going on to view the example code. At this point you’ll probably have a shock at how much AS3 code needs to be written to implement such a simple menu. Not at all what you are used to in Flex.

If you are thinking there must be a way to do this using a component. You’d be right, but it is documented in the “Using the Flex AIR components” “About the FlexNativeMenu control“section not the “Windows, menus and taskbars” section.

new SWFObject (2.0)

The authors of SWFObject and UFO have been working hard on a new version released yesterday as SWFObject 2.0. The project is now on googlecode. Geoff’s announcement is here.

As stated in my earlier posts I consider use of SWFObject to be best practice for embedding SWFs in web pages.

what happened to my tweets?

The dark bit of sky in this blog’s header contains a simple SWF generated from pure AS3 that uses the Twitter API to collect and display my history of twitter messages. Unfortunately there is now a cross-domain policy file preventing any SWF other than those hosted actually from the twitter.com domain from accessing the feed. Apparently due to a security issue. The current suggested work-around is for me to write a proxy php script to sit on my own server to relay the feed request. Which I might do if I can be arsed, but I’m feeling grumpy today so I’m more likely to abandon Twitter all together – not that I ever over used it.

Twitter development talk on google groups has a thread that reveals some of the thinking going into solving the issue.