March 30, 2005

XPath, Flash and RSS

Filed under: Uncategorized — Steve @ 9:09 PM

Writing about web page http://www.xfactorstudio.com/ActionScript/AS2/XPath/

Grrr; want to try some experiments with Flash and a Warwick Blogs RSS feed, search Google for some pointers on parsing feeds using AS, can’t find anything particularly useful so I attempt something anyway, after 2 hours this evening it’s almost working but I’m stuck on something silly, try Google again, find a link to the Actionscript version of the XPathAPI, discover it’s already built into Flash 7, and all I need is the classpath and to drag the Data Binding Classes into the Library to access a really easy way of navigating the feed. 10 mins later I have a lovely collection of arrays full of titles, items, authors etc. plugged into my display array function. I’m sure someone mentioned XPath to me before I started this. Next time I’ll pay attention. For the record;

import mx.xpath.XPathAPI;
var rssfeed_xml = new XML();
rssfeed_xml.ignoreWhite = true;
rssfeed_xml.load(“http://blogs.warwick.ac.uk/showall/newentries/?rss=rss_2_0″);
rssfeed_xml.onLoad = function(success) {
if (success)
{ var titlePath:String = “/rss/channel/item/title”;
title_array = mx.xpath.XPathAPI.selectNodeList(this.firstChild, titlePath);
for (var i = 0; i<title_array.length; i++)
{ trace(title_array[i].firstChild.nodeValue);}}}

etc..

No more of that nextSibling, firstChild multi-function rubbish for me. That turned 4 functions and about 100 lines of code into 20. Conscious incompetence, here I come…

March 18, 2005

Director vs Flash notes

Filed under: Uncategorized — Steve @ 10:52 AM

I’ve spent the last 5 weeks using Director MX for a Uni homework project. We had to develop a multimedia application that portrayed a range of historic locations, with a range of included content for a couple of them (animation, narration, rollovers, sound, video etc.). Having used Flash for while, there are some interesting comparisons;

  • Library and Cast; Director and Flash use similar metaphors for most objects, including a Stage and a Library or Cast of objects, but they are completely opposed in terms of cast workflow; in Flash you draw or import objects on to the Stage first, then convert them to Library members; in Director you import members into the Cast first, then you can use them on the Stage.

Note to self; when deploying the projector file, check and double-check that Director has created relative paths to directories and external or internal cast members; your application may play fine on your host machine but will be utterly broken if relative linking isn’t implemented. Director can annoyingly auto-generate absolute links in the CMP after initial import so force the path (by typing it in), save, publish and cross your fingers as you try the file on another computer. Next time you open the file check again. Do this at least 2 days before your assignment deadline because the task of re-pathing a cast of 300 sprites with 2 hours to go is somewhat stressful.

  • Timeline/Score; this includes the principle of layering too because layers are attached to the timeline or score; Director is primarily a screen-based application; Flash can work in this way but also supports other methods of delivery, and its screen-application mode works differently. In Director everything appears on a single timeline, and switching is achieved through playFrame commands. In Flash this is achieved by calling the screen object directly. In both applications this means that a screen always has a timeline, but in Director screens are sequentially placed on a master timeline. Both use layering, but Flash is more explicit in its concept.

  • Tweening/Animation; similar in both, although I found Director was simpler (although less well-featured).

  • Scripting; Lingo vs Actionscript. The latest versions of Flash use a semi-OO approach to scripting, with object references and handlers. Lingo is a little more ‘odd’; although it uses method handlers some of the syntax takes a bit of getting used to. Programming can be problematic because code can exist in a number of places simultaneously and may be generated by a UI component or manually; on the score, in a keyframe, on a cast member, or a sprite) and so debugging someone else’s application can be a nightmare. Flash is better at data connectivity though; the built-in XML and data-binding make it far better suited to web-based applications.

  • Application layout; both can be annoying, with windows and panels everywhere; it’s hard to find a suitable compromise between seeing the Stage and the various panels you need to edit a particular object without having to close, minimise, or drag panles all over the place. Once you do get a decent compromise things get a lot easier.