News:

GinGly.com - Used by 85,000 Members - SMS Backed up 7,35,000 - Contacts Stored  28,850 !!

Main Menu

Loading Video with XML

Started by Kalyan, May 13, 2009, 08:26 AM

Previous topic - Next topic

Kalyan

Loading Video with XML


Here is the XML code:


<?xml version="1.0" encoding="utf-8" standalone="yes"?>

<videos>

<video>
<video>_mov/bronx_parksouth.flv</video>
<thumb>_mov/_thumbs/thumb1.jpg</thumb>
<path></path>
<desc>This is a video info to come</desc>
</video>

<video>
<video>_mov/bronx_parksouth.flv</video>
<thumb>_mov/_thumbs/thumb2.jpg</thumb>
<path></path>
<desc>This is a video info to come</desc>
</video>
</videos>




Here is the AS2 code:

function loadXML(loaded) {

if (loaded) {

xmlNode = this.firstChild;
video = [];
description = [];
thumbnails = [];
popupvideo = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {

video[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
description[i] = xmlNode.childNodes[i].childNodes[3].firstChild.nodeValue;
thumbnails[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
thumbnails_fn(i);
popupvideo[i] = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue;



}
firstvideo();
trace(video);
trace(thumbnails);

} else {

content = "file not loaded!";

}

}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("_xml/videos.xml");
/////////////////////////////////////
listen = new Object();
listen.onKeyDown = function() {

if (Key.getCode() == Key.LEFT) {

back_btn();

} else if (Key.getCode() == Key.RIGHT) {

frw_btn();

}

};
Key.addListener(listen);
back_btn.onRelease = function() {

prevvideo();

};
frw_btn.onRelease = function() {

nextvideo();

};
/////////////////////////////////////
p = 0;
this.onEnterFrame = function() {

filesize = picture.getBytesTotal();
loaded = picture.getBytesLoaded();
preloader._visible = true;
if (loaded != filesize) {

preloader.preload_bar._xscale = 100*loaded/filesize;

} else {

preloader._visible = false;
if (videoObj._alpha<100) {

videoObj._alpha += 10;

}

}

};

//////////////////////////////////////////////




/*
//launching pop-up
blank.onRelease = function() {
launchvideo();
};

function launchvideo() {
//trace("this is picture "+ popupvideo[p]);
getURL("javascript:Launch2('"+popupvideo[p]+"')");

}
function openWinCentre(url, winName, w, h, toolbar, location, directories, status, menubar, scrollbars, resizable) {

getURL("javascript:var myWin; if(!myWin || myWin.closed){myWin = window.open('"+url+"','"+winName+"','"+"width="+w+",height="+h+",toolbar="+toolbar+",location="+location+",directories="+directories+",status="+status+",menubar="+menubar+",scrollbars="+scrollbars+",resizable="+resizable+",top='+((screen.height/2)-("+h/2+"))+',left='+((screen.width/2)-("+w/2+"))+'"+"')}else{myWin.focus();};void(0);");

}
*/



/////////////////////



//button actions
function nextvideo() {

if (p<(total-1)) {

p++;
if (loaded == filesize) {

videoObj._alpha = 0;
videoObj.contentPath(video[p],1);
desc_txt.text = description[p];
//picture_num();

}

}

}
function prevvideo() {

if (p>0) {

p--;
videoObj._alpha = 0;
videoObj.contentPath(video[p],1);
desc_txt.text = description[p];
//picture_num();

}

}


// buttons
video1_btn.onRelease = function() {
trace(vidArray[0]);
// videoObj_1 - instance name of FLVPlayback component
videoObj_1.contentPath = vidArray[0];
};

video2_btn.onRelease = function() {
trace(vidArray[1]);
videoObj_2.contentPath = vidArray[1];
};


function firstvideo() {

if (loaded == filesize) {

videoObj._alpha = 0;
videoObj.contentPath = (video[0], 1);
desc_txt.text = description[0];
//picture_num();

}

}
function picture_num() {

current_pos = p+1;
pos_txt.text = current_pos+" / "+total;

}


//thumbnail code

function thumbNailScroller() {

// thumbnail code!
this.createEmptyMovieClip("tscroller",1000);
scroll_speed = 10;
tscroller.onEnterFrame = function() {

if ((_ymouse>=thumbnail_mc._y) && (_ymouse<=thumbnail_mc._y+thumbnail_mc._height)) {

if ((_xmouse>=(hit_right._x-40)) && (thumbnail_mc.hitTest(hit_right))) {

thumbnail_mc._x -= scroll_speed;

} else if ((_xmouse<=40) && (thumbnail_mc.hitTest(hit_left))) {

thumbnail_mc._x += scroll_speed;

}

} else {

delete tscroller.onEnterFrame;

}

};

}
function thumbnails_fn(k) {

thumbnail_mc.createEmptyMovieClip("t"+k,thumbnail_mc.getNextHighestDepth());
tlistener = new Object();
tlistener.onLoadInit = function(target_mc) {

target_mc._x = hit_left._x+(eval("thumbnail_mc.t"+k)._width+5)*k;
target_mc.pictureValue = k;
target_mc.onRelease = function() {

p = this.pictureValue-1;
nextvideo();

};
target_mc.onRollOver = function() {

this._alpha = 50;
thumbNailScroller();

};
target_mc.onRollOut = function() {

this._alpha = 100;

};

};
video_mcl = new MovieClipLoader();
video_mcl.addListener(tlistener);
video_mcl.loadClip(thumbnails[k],"thumbnail_mc.t"+k);

}

stop();