I’m trying to figure out how to track clicks from an xml fed video streamer. I read the article at Google about adding the event to a basic Flash button:
http://adwords.google.com/support/bin/answer.py?answer=27243&ctx=sibling
But how do you compile the info from an external XML document?
The beauty of XML is the ease of switching out content. I just don’t know enough about AS to tell it to not only stream the video but also to send urchinTracker info back to my Analytics report.
Here’s an article I found that’s getting me …closer:
http://studio.brightcove.com/library/howto/js-tracking/
And here’s the code I’m using based on a Video Jukebox tutorial I found online:
// variable declarations
var menu_xml:XML = new XML();
var liListener:Object = new Object(); // Listener Step 1: create generic Listener object
var menuURL:String = "videomenu.xml";
var media_pb:mx.controls.MediaPlayback;
// function declarations
function traverseXML (node_xml:XMLNode):Void {
var rootElement_xml:XMLNode = node_xml.firstChild; // always start by accessing root node;
var nbrElements:Number = rootElement_xml.childNodes.length; // make for() loop cleaner;
selection_li.addItem(" ~~ Select a Video ~~ ", "");
for(i=0; i<nbrElements; i++) { // loop through child nodes
label_str = rootElement_xml.childNodes*.attributes.label; // label attribute
data_str = rootElement_xml.childNodes*.attributes.data; // data attribute
selection_li.addItem(label_str, data_str);
}
}
// event callbacks
menu_xml.onLoad = function (success) {
if (success) {
traverseXML(menu_xml); // walk through all child nodes
} else {
status_txt.text = "Error accessing " + menuURL;
}
}
liListener.change = function (eventObj) { // Listener Step 2:
if (eventObj.target.value != "") {
title_txt.text = eventObj.target.text;
media_pb.setMedia( eventObj.target.value, "FLV" );
media_pb.play(); // play if stopped
}
}
// initial frame actions
menu_xml.ignoreWhite = true;
menu_xml.load( menuURL );
selection_li.addEventListener("change", liListener); // Listener Step 3:
And my xml string looks like:
<videolist>
<selection label="Test Video01 Date: 2007/03/12" data="flv/video01.flv" />
<selection label="Test Video02 Date: 2007/03/12" data="flv/video02.flv" />
</videolist>
I just want to track the “data” (not the “selection label”).
thanks for any help you can offer!