[LEFT]I’m going through the ‘gotoandlearn.com’ tut about adding a list component to a .flv player. The XML is very basic, with two elements - one being the url to the video, the other being descriptive text for the list component. The list component is then populated by an Array script.
What I’m trying to do is add a third element to the XML which would be the url to an external .swf. Writing the XML is the easy part. I need to understand how to call it out in flash.
I’ve got an objectListener listening for the end of the .flv to load the external .swf to level 1 - and it works fine when I hard code loadMovieNum(path=“blah”,1) into the if statement, so I’m guessing that it jus a matter of writing 'loadMovieNum(path to the third element in the XML file, 1);
I know someone here knows the answer to this… Here’s my code.
ActionScript Code:
[FONT=Courier New][LEFT][COLOR=#000000]**var**[/COLOR] nc:[COLOR=#0000ff]NetConnection[/COLOR] = [COLOR=#000000]**new**[/COLOR] [COLOR=#0000ff]NetConnection[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR];
nc.[COLOR=#0000ff]connect[/COLOR]COLOR=#000000[/COLOR];
[COLOR=#000000]var[/COLOR] ns:[COLOR=#0000ff]NetStream[/COLOR] = [COLOR=#000000]new[/COLOR] [COLOR=#0000ff]NetStream[/COLOR]COLOR=#000000[/COLOR];
ns.[COLOR=#0000ff]setBufferTime[/COLOR]COLOR=#000000[/COLOR];
myVideo.[COLOR=#0000ff]attachVideo[/COLOR]COLOR=#000000[/COLOR];
//path = [COLOR=#ff0000]“logos/”[/COLOR];
[COLOR=#808080]//ns.play(path+“part1.flv”);[/COLOR]
[COLOR=#808080]/////////XML/////////////[/COLOR]
[COLOR=#000000]var[/COLOR] vlist:[COLOR=#0000ff]XML[/COLOR] = [COLOR=#000000]new[/COLOR] [COLOR=#0000ff]XML[/COLOR]COLOR=#000000[/COLOR];
vlist.[COLOR=#0000ff]load[/COLOR]COLOR=#000000[/COLOR];
vlist.[COLOR=#0000ff]ignoreWhite[/COLOR] = [COLOR=#000000]true[/COLOR];
vlist.[COLOR=#0000ff]onLoad[/COLOR] = [COLOR=#000000]function[/COLOR]COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#000000]var[/COLOR] videos:[COLOR=#0000ff]Array[/COLOR] = [COLOR=#0000ff]this[/COLOR].[COLOR=#0000ff]firstChild[/COLOR].[COLOR=#0000ff]childNodes[/COLOR];
[COLOR=#0000ff]for[/COLOR] [COLOR=#000000]([/COLOR]i=[COLOR=#000080]0[/COLOR]; i<videos.[COLOR=#0000ff]length[/COLOR]; i++[COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
videoList.[COLOR=#000080]addItem[/COLOR][COLOR=#000000]([/COLOR]videos[COLOR=#000000][[/COLOR]i[COLOR=#000000]][/COLOR].[COLOR=#0000ff]attributes[/COLOR].[COLOR=#000080]desc[/COLOR], videos[COLOR=#000000][[/COLOR]i[COLOR=#000000]][/COLOR].[COLOR=#0000ff]attributes[/COLOR].[COLOR=#0000ff]url[/COLOR], videos[COLOR=#000000][[/COLOR]i[COLOR=#000000]][/COLOR].[COLOR=#0000ff]attributes[/COLOR].[COLOR=#0000ff]url[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#000000]}[/COLOR]
ns.[COLOR=#0000ff]play[/COLOR]COLOR=#000000[/COLOR];
videoList.[COLOR=#000080]selectedIndex[/COLOR] = [COLOR=#000080]0[/COLOR];
[COLOR=#000000]}[/COLOR];
[COLOR=#000000]var[/COLOR] vidList:[COLOR=#0000ff]Object[/COLOR] = [COLOR=#000000]new[/COLOR] [COLOR=#0000ff]Object[/COLOR]COLOR=#000000[/COLOR];
vidList.[COLOR=#000080]change[/COLOR] = [COLOR=#000000]function[/COLOR]COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]
ns.[COLOR=#0000ff]play[/COLOR]COLOR=#000000[/COLOR];
[COLOR=#0000ff]unloadMovieNum[/COLOR]COLOR=#000000[/COLOR];
[COLOR=#000000]}[/COLOR];
videoList.[COLOR=#000080]addEventListener[/COLOR][COLOR=#000000]([/COLOR][COLOR=#ff0000]“change”[/COLOR], vidList[COLOR=#000000])[/COLOR];
ns.[COLOR=#0000ff]onStatus[/COLOR] = [COLOR=#000000]function[/COLOR]COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#0000ff]if[/COLOR] [COLOR=#000000]([/COLOR][COLOR=#0000ff]object[/COLOR].[COLOR=#000080]code[/COLOR] == [COLOR=#ff0000]“NetStream.Play.Start”[/COLOR][COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#000000]}[/COLOR] [COLOR=#0000ff]else[/COLOR] [COLOR=#0000ff]if[/COLOR] [COLOR=#000000]([/COLOR][COLOR=#0000ff]object[/COLOR].[COLOR=#000080]code[/COLOR] == [COLOR=#ff0000]“NetStream.Play.Stop”[/COLOR][COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#808080]//loadMovieNum(path+“logo.swf”, 1);[/COLOR]
[COLOR=#0000ff]loadMovieNum[/COLOR][COLOR=#000000]([/COLOR]videoList.[COLOR=#000080]getItemAt[/COLOR]COLOR=#000000[/COLOR].[COLOR=#0000ff]attributes[/COLOR].[COLOR=#0000ff]data[/COLOR], [COLOR=#000080]1[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#000000]}[/COLOR]
[COLOR=#000000]}[/COLOR];
And here is the basic XML code.
ActionScript Code:
[FONT=Courier New][LEFT]<?[COLOR=#0000FF]xml[/COLOR] [COLOR=#0000FF]version[/COLOR]=[COLOR=#FF0000]"1.0"[/COLOR] encoding=[COLOR=#FF0000]"ISO-8859-1"[/COLOR]?>
<videos>
<video [COLOR=#0000FF]url[/COLOR]=[COLOR=#FF0000]"flvs/test.flv"[/COLOR] desc=[COLOR=#FF0000]"Test"[/COLOR] [COLOR=#0000FF]url[/COLOR]=[COLOR=#FF0000]"logos/logo.swf"[/COLOR] />
<video [COLOR=#0000FF]url[/COLOR]=[COLOR=#FF0000]"flvs/part2.flv"[/COLOR] desc=[COLOR=#FF0000]"Part Two"[/COLOR] [COLOR=#0000FF]url[/COLOR]=[COLOR=#FF0000]"logos/logo.swf"[/COLOR]/>
</videos>
[/LEFT]
[/FONT]
[/LEFT]
[/FONT]Please help me with this. This is the last snag in my player. Thanks!! :snug:
[/LEFT]