0 Replies - 908 Views - Last Post: 05 June 2008 - 06:25 AM

#1 jibber4568  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 51
  • Joined: 11-February 08

AS3 XML Help

Posted 05 June 2008 - 06:25 AM

I have an XML based video player that works fine.

The problem i have is that i want to be able to change the XML file when the plyaer gets to a particular frame.

I am sure in AS2 i just placed the entire code on another frame but with a different XML file.

I have tried this in AS3 but get errors of duplicate functions. To rectify this i tried calling all functions "loader2" for example.

This is my code if someone could tell me what i need to do to load a different XML file on another frame i would very much appreciate it.

Also what have missed in order to enable auto play? At the moment i have to select the first video in order to enable playback.

Cheers
stop();
import fl.video.FLVPlayback;
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, onloaded);

myList.addEventListener(Event.CHANGE, itemChange);

function itemChange(e:Event):void {
	//myPlayer.load(myList.selectedItem.data);
	myPlayer.play(""+myList.selectedItem.data);
}

var xml:XML;

function onloaded(e:Event):void {

	xml = new XML(e.target.data);
	var il:XMLList = xml.channel.item;
	for (var i:uint=0; i<il.length(); i++) {
		myList.addItem({label:il.description.text()[i],
		data:il.title.text()[i]});
	}
}

loader.load(new URLRequest("CupFinal.XML"));
myPlayer.addEventListener(Event.COMPLETE, nextFLV);
function nextFLV(e:Event):void {

	var ds = myList.selectedIndex;
	var dsl = myList.length;
	if (myList.selectedIndex == 0) {
		trace("if = yes: "+dsl);
		myList.selectedIndex = (+1);
		myPlayer.play(""+myList.selectedItem.data);
	} else {
		if ((ds+1) == dsl) {
			myList.selectedIndex = 0;
			myPlayer.play(""+myList.selectedItem.data);
		} else {
			trace("if = else");
			myList.selectedIndex = (ds+1);
			myPlayer.play(""+myList.selectedItem.data);
		}
	}
}



Is This A Good Question/Topic? 0
  • +

Page 1 of 1