Welcome to Dream.In.Code
Getting Help is Easy!

Join 119,726 Programmers for FREE! Ask your question and get quick answers from experts. There are 1,398 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



AS3 XML Help

 
Reply to this topicStart new topic

AS3 XML Help

jibber4568
post 5 Jun, 2008 - 06:25 AM
Post #1


New D.I.C Head

*
Joined: 11 Feb, 2008
Posts: 40

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
CODE

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);
        }
    }
}
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 10/15/08 04:11PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month