Archive for January, 2005

Using XPath with Flash

A blog post of mine from yesteryear, but the issue came up recently (and the class is undocumented) so I thought I’d reblog it.

Flash MX 2004 introduced the XPathAPI class which allows you to do simple XPath searches within Flash. This can be very useful for searching XML packets based on node names and attribute values.

In order to use XPath searches within Flash you first need to include the XPathAPI class into your Flash library by including the DataBindingClass if it hasn’t been included already. If you’ve already set up bindings this class may have been included automatically, otherwise you’ll need to select the class from the common libraries by selecting Window > Other Panels > Common Libraries > Classes. From the Classes.fla library panel you can simply drag a copy of the DataBindingClasses component into your current Flash document’s library. Now you can import the class by typing “import mx.xpath.XPathAPI;” or by using the classes fully qualified name when accessing its methods by prefixing the class’ methods with mx.xpath.XPathAPI.”.

The XPath class has two methods; selectNodeList and selectSingleNode. The selectNodeList method returns an array of XML nodes matching the XPath expression, whereas the selectSingleNode returns only the first matching node.

You can see an example of the XPath API in ActionScript below, before you can test the movie you have to make sre that you have a copy of the DataBindingClasses component in your movie’s library by dragging it from Common Libraries > Classes into your current Flash movie’s library.

import mx.xpath.XPathAPI;
var rssfeed_xml:XML = new XML();
rssfeed_xml.ignoreWhite = true;
rssfeed_xml.load("http://www.markme.com/dehaan/index.rdf");
rssfeed_xml.onLoad = function(success:Boolean) {
  if (success) {
    var titlePath:String = "/rdf:RDF/item/title";
    var title_array:Array = XPathAPI.selectNodeList(this.firstChild, titlePath);
    for (var i = 0; i<title_array.length; i++) {
      trace(title_array[i].firstChild.nodeValue);
    }
  } else {
    trace("error loading XML");
  }
};

If you want more info on this class, check out Nate Weiss’ book here.

Friday Macrochat: Introducing the Flash Player Detection Kit

Intro to the Flash Player Detection Kit Macrochat
Friday, January 28, 2005
1:00 PM – 2:00 PM US/Eastern

Register here:
www.macromedia.com/cfusion/event/index.cfm?event=detail&id=133668&loc=en_us

Macromedia Senior Technical Support Engineer Jason Wylie will be presenting
“Introducing the Flash Player Detection Kit”. Tune in and learn how to
create a Flash Player detection script from scratch, use the Detection Kit
to create the script, and understand why detecting the Flash Player on a
website is vitally important to ensuring your visitors have the best web
experience possible.

What You Will Learn

* What is Flash Player detection?
* Why do you need to detect the player?
* How do you detect the player
* Detection options and reviewing the code it creates
* Dreamweaver Extensions
* 3rd party methods
* Moock FPI
* BrowserHawk
* Multiple sites (one HTML and one Flash site)

Pictures of new Macromedia offices at 601 Townsend

Some of Macromedia moved into the new headquarters today, at 601 Townsend, which is across the street from the old building. Some info about the building is here: www.markme.com/md/archives/006857.cfm Here are some pics of the new offices, from the inside :) Sorry for the blurriness – it was dark and I didn’t have the flash on.


Heading to new office with all my crap (two work laptops) in tow.


Arriving at the new building – front door.

=== MORE PICS! View the extended entry… ===

Continue reading…

Improved LiveDocs: track, rss, reporting

Good news, LiveDocs is improved. Check out some of the new features. Browse to a page in LiveDocs and check out some new links on the bottom of the page.

http://livedocs.macromedia.com/flash/mx2004/main_7_2/00000734.html

At the bottom of the page, you’ll see an RSS feed of the page, a link to send you an email when a comment is posted, and a link to the Comment Report, allowing you to do detailed searches:

http://www.macromedia.com/cfusion/livedocs/report/index.cfm?loc=en_us

Now you have a lot more access to the comments people make. Note that the RSS feeds link displays only when a page has comments.

Enjoy and happy livedoc-ing.

Mac Mini

Sorry for the OT-ness and two posts, but this is SO SWEET:

http://www.apple.com/macmini/

Check out the specs:

http://www.apple.com/macmini/specs.html

Apple keynote – the $499 computer revealed

Just wrapping up, according to the alerts. Check out some notes here:

http://www.macmerc.com/

and of course – see the iPod Shuffle on the front of:

http://www.apple.com/

Highlights include:

iPod Shuffle (small, 1gig, flash based)

Mac mini (!!!!) $499/$599 (out Jan 22)

iWork (“office-like”, rebuilt AppleWorks)

iLife ’05

Tweening with ActionScript

So the Tween/Transition stuff wasn’t put in the Flash documentation. Good news is that there’s now an article on the Developer Center about using the classes. Bad news is the article came from me ;)

If you haven’t used the classes yet, check the article out out anyway, see if it helps you with your Flash work. Fairly simple article (had to keep that word count in check…)

macromedia.com/devnet/mx/flash/articles/tweening.html

If you have any ideas for expanding the content, or wish to share some of your own tips, please comment below.

Survey day: What docs do you use the most?

Hope you all had a nice and safe holiday.

Today is Tuesday survey day! Today I’d like to get your feedback on the areas where you use the Flash docs the most, and the areas where you’d like to see the most improvement, focus, examples, etc.

You might notice that the documentation is separated into books. If you go to the Flash Help panel and click the “Table of Contents” button, you can see their titles. Examples of the books are:

* Getting Started tutorials
* Using Flash
* Using ActionScript in Flash (the chaptery sections on ActionScript)
* ActionScript Language Reference (aka: dictionary)
* Using Components (which contains the Components Dictionary – please feel free to count that as a separate book!)
* Flash JavaScript Dictionary
* Data Tutorials

And ones after that are books that likely installed with your components.

Anyway, please consider the following for this survey:

* What book(s) do you use the most?
* Where would you personally like to see the “most improvement” or attention? (Maybe you don’t read a book now becuase it’s poor – but you would read it if it was good/improved).
* How do you use the books? (Ie: do you look for tutorials, code snippets, high-level workflow stuff, etc?)
* What are you: a developer, a designer, or a hybrid between the two – a deseloper?
* Any other feedback?

Thanks!