Hi,
I’m having troubles trying to make an instance of the FLVPlayback component plays dynamically some flvs referenced in a xml file.
so i have my xml file called “flvNamesX.xml” in which all the flvs on my server are referenced.
<?xml version="1.0"?>
<flvFiles>
<flv name="s01e01_clip320x240.flv" />
<flv name="s01e02_clip320x240.flv" />
<flv name="s01e03_clip320x240.flv" />
<flv name="s01e04_clip320x240.flv" />
<flv name="s01e05_clip320x240.flv" />
<flv name="s01e06_clip320x240.flv" />
<flv name="s01e07_clip320x240.flv" />
<flv name="s01e08_clip320x240.flv" />
<flv name="s01e09_clip320x240.flv" />
</flvFiles>
With AS, i load the xml file.
When the xml file is loaded i create an instance of the FLVPlayback component on stage and want it to play the desired flv on the spot.
function loadXML(loaded) {
if (loaded) {
_global.nameArray = new Array();
trace("this.firstChild.childNodes = " + this.firstChild.childNodes);
var a = this.firstChild.childNodes;
for (var c = 0; c < a.length; c++){
trace("a[" + c + "].attributes.name = " + a[c].attributes.name);
_global.nameArray.push(a[c].attributes.name);
}
trace(_global.nameArray[5]);
var flvId:Number = 3;
var theFlv=_global.nameArray[flvId];
createFLVcomp(theFlv);
} else {
trace("file not loaded!");
}
}
flvNames = new XML();
flvNames.ignoreWhite = true;
flvNames.onLoad = loadXML;
flvNames.load("flvNamesX.xml");
//Creates an FLVPlayback instance onstage
function createFLVcomp(flvToBePlayed){
var basePath:String = "path/to/my/flvs/";
import mx.video.*;
this.attachMovie("FLVPlayback", "my_FLVPlybk", 10, {width:320, height:240, x:100, y:100});
my_FLVPlybk.skin = "MojaveExternalAll.swf";
my_FLVPlybk.contentPath = basePath + flvToBePlayed;
trace(basePath + flvToBePlayed);
}
stop();
The problem is here, in the last of those 3 lines:
var flvId:Number = 3;
var theFlv=_global.nameArray[flvId];
createFLVcomp(theFlv);
Instead of this line,
createFLVcomp(theFlv);
if i pass the argument directly as a string like this one:
createFLVcomp("s01e01_clip320x240.flv");
everything works fine.
Here’s the output window text when i run the code;
this.firstChild.childNodes = <flv path="s01e01_clip320x240.flv" />,<flv path="s01e02_clip320x240.flv" />,<flv path="s01e03_clip320x240.flv" />,<flv path="s01e04_clip320x240.flv" />,<flv path="s01e05_clip320x240.flv" />,<flv path="s01e06_clip320x240.flv" />,<flv path="s01e07_clip320x240.flv" />,<flv path="s01e08_clip320x240.flv" />,<flv path="s01e09_clip320x240.flv" />
a[0].attributes.path = s01e01_clip320x240.flv
a[1].attributes.path = s01e02_clip320x240.flv
a[2].attributes.path = s01e03_clip320x240.flv
a[3].attributes.path = s01e04_clip320x240.flv
a[4].attributes.path = s01e05_clip320x240.flv
a[5].attributes.path = s01e06_clip320x240.flv
a[6].attributes.path = s01e07_clip320x240.flv
a[7].attributes.path = s01e08_clip320x240.flv
a[8].attributes.path = s01e09_clip320x240.flv
s01e06_clip320x240.flv
path/to/my/flvs/s01e06_clip320x240.flv
I want to know why isnt it working when i use a variable instead.
Or is there a better, more efficient way to do want i’m looking for?
I need assistance on this one.
thanks to all.