Ok, so in my AS3, I have the following code that loads in XML content to the SWF:
var xml:XML;
var urlLoader:URLLoader = new URLLoader();
var urlRequest = new URLRequest("playlist.xml");
urlLoader.load(urlRequest);
urlLoader.addEventListener(Event.COMPLETE, onComplete)
function onComplete (evt:Event):void
{
try
{
var xml:XML= new XML(evt.target.data);
processXML (xml);
}
catch (evt:TypeError)
{
trace ("Could not parse text into XML");
trace (evt.message);
}
}
function processXML(xml:XML):void
{
for each (var property:XML in xml.vid)
{
trace(xml.vid.attribute("src"));
trace(xml.vid.attribute("thumb"));
trace(xml.vid.attribute("cap"));
//if there will be always ony one record in xml file you can set flv
//playback source here
myVideo.source=xml.vid.attribute("src");
myPoster.source=xml.vid.attribute("thumb");
captioning.source=xml.vid.attribute("cap");
//rest of thing should be also handle here
//if there will be more records
//you should sotrt data first
}
}
Now, here’s where it gets tricky… I have four other “variables” that I’d like to get pulled into the AS. (They’re used for Omniture Reporting) I have them highlighted in red below.
myVideo.addEventListener(MetadataEvent.CUE_POINT, cp_listener);
myVideo.addASCuePoint(**[COLOR="Red"]0.01[/COLOR]**, "sendOmnitureStart");
myVideo.addASCuePoint(**[COLOR="Red"]134.0[/COLOR]**, "sendOmnitureMidPoint");
myVideo.addASCuePoint(**[COLOR="Red"]266.0[/COLOR]**, "sendOmnitureEnd");
function cp_listener(eventObject:MetadataEvent):void {
trace("Elapsed time in seconds: " + myVideo.playheadTime);
trace("Cue point name is: " + eventObject.info.name);
trace("Cue point type is: " + eventObject.info.type);
var trap:String;
switch (eventObject.info.name) {
case "sendOmnitureStart":
trap = sendOmniture('Started Playback');
break;
case "sendOmnitureMidPoint":
trap = sendOmniture('Playback Midpoint');
break;
case "sendOmnitureEnd":
trap = sendOmniture('Finished Playback');
break;
}
}
function sendOmniture(eventName) {
trace(eventName);
var OmnitureURL:String = "XXXXXX=session&j=XXXXX&pageName=" + eventName + ": **[COLOR="Red"]THIS IS THE MOVIE NAME[/COLOR]**"
trace(OmnitureURL);
var omnitureCall:URLRequest = new URLRequest(OmnitureURL);
omnitureCall.contentType = "image/gif";
omnitureCall.method = URLRequestMethod.GET;
var loader:URLLoader = new URLLoader();
try
{
loader.load(omnitureCall);
}
catch (error:ArgumentError)
{
trace("An ArgumentError has occurred.");
}
catch (error:SecurityError)
{
trace("A SecurityError has occurred.");
}
//trace(omnitureCall);
}
So now, I have an XML doc that looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<playlist id="Here's The Video" >
<vid desc="Introduction to Biological Terrorism Agents"
src="Introduction.flv"
thumb="Introduction.jpg"
cap="Introduction.xml"
omName="**[COLOR="Red"]Introduction Video[/COLOR]**"
omStart="**[COLOR="Red"]0.01[/COLOR]**"
omMiddle="**[COLOR="red"]134.0[/COLOR]**"
omEnd="**[COLOR="red"]266.0[/COLOR]**" />
</playlist>
So my question is, how do I get the three “om” items in the XML loaded into the areas of AS (that are red) above?
Thanks!
Joe