Ok, so here is my new question, How to get an array from an XML file, bring it into flash, and set up a playlist from the XML file to play a series of FLV files (that also loops). Also to include the ability to add to the list in the XML and flash automatically recognize the new item and throw it in the playlist on next runtime.
Currently I have an xml file being loaded in to control the prices on a menuboard.
import flash.display.Loader;
import flash.net.URLLoader;
import flash.events.Event;
import flash.net.URLRequest;
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.addEventListener(Event.COMPLETE, loadXML);
var xmlData:XML = new XML();
function loadXML(e:Event):void{
xmlData=new XML(e.target.data);
SkinnyB.text = xmlData.myXMLList.ListItem[0].SkinnyB.text();
FattyB.text = xmlData.myXMLList.ListItem[0].FattyB.text();
HeavyB.text = xmlData.myXMLList.ListItem[0].HeavyB.text();
MiniB.text = xmlData.myXMLList.ListItem[0].MiniB.text();
//etc etc
}
xmlLoader.load(new URLRequest("BarbXML.xml"));
My xml currently looks like this
<?xml version="1.0" encoding="utf-8"?>
<XML1>
<myXMLList>
<Menu1AdVideo>
<video url='DrinkAd.flv' />
<video url='MenuAd.flv' />
<video url='PromoAd.flv' />
<video url='DemoAd.flv' />
</Menu1AdVideo>
<ListItem>
<SkinnyB>5.79</SkinnyB>
<FattyB>6.49</FattyB>
<HeavyB>6.79</HeavyB>
<MiniB>4.39</MiniB>
</ListItem>
</myXMLList>
</XML1>
The AS3 code pulling the XML is located in the root of the Flash file, and the Movie clip that I am wanting to add these flv videos to play through is nested inside another Movieclip from the root.
I currently have code thanks to Booya to play a list of FLV files and loop them
var videoList:Array = [DrinkAd.flv", "MenuAd.flv", "PromoAd.flv"];
//we alos define the currentIndex here:
var currentIndex:int = 0;
//now your previously posted stuff
var vid:Video = new Video(1040, 360);
addChild(vid);
var nc:NetConnection = new NetConnection();
nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
nc.connect(null);
var ns:NetStream = new NetStream(nc);
ns.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler)
vid.attachNetStream(ns);
var listener:Object = new Object();
listener.onMetaData = function(evt:Object):void {};
ns.client = listener;
function playVideo():void{
ns.play(videoList[(currentIndex++)%videoList.length]);
}
function netStatusHandler( event:NetStatusEvent ) :void
{
if(event.info.code == "NetStream.Play.Stop")
playVideo();
}
playVideo();
The following was put forth by Booya, though I am unsure as to where to place it and what to follow it with etc.
currentIndex++
currentIndx will be post-increment by each call -
means it returns the currentvalue and adds 1 to the value..
% modulo
returns the rest from an division -
5%3 = 2 etc.
I am going to start trying to throw code together and see what comes out, though I am very rough at building my own code so help with this would be great! Thank you so much.