Community discussion forum

Problem looping through xml file to play a flv video file

  • 4 months ago

    Hi There

    I am having difficulty understanding how to loop through an xml file. I have a flash movie which has an image menu that the user can move through. I would like the user to be able to click on an image and a corresponding flv video file plays. I understand that I need an FLV playback object on the stage/screen but I can't seem to program the actionscript.

    Actionscript3 Code: //Image Slider By John Bezanis for SWFspot //Settings to play with //the height of the images when not stretched var maxheight = 50; //the y position of the "floor" or where the images sit on var floor = 80; //The amount an image scales to as the mouse gets closer var curvedistance = 150; //The amount of gap in between each image var sidegap = 5; //The background color of the document. This is used for the reflection var bgcolor = 0x000000; /no more settings to play with below here */ //Initialize the image count to 0 var imagecount = 0; //if the get parameter "xmlfile" is not set, change the xml file to load the data to a default name if (_root.xmlfile == undefined || _root.xmlfile == "") { //default name for the xml feed _root.xmlfile = "sliderfeed.xml"; } var myXml:XML = new XML(); myXml.ignoreWhite = true; //Load the xml file myXml.load(_root.xmlfile); //run when the xml file has loaded myXml.onLoad = function() { //parse the xml file and load in the images loadImages(); }; //start loading in the images function loadImages() { //traverse through each pic of the xml file for (imageIndex=0; imageIndex if (curmouseover>=myXml.childNodes[0].childNodes.length) { //move the last pic to the stage width minus the width of the pic eval("im"+Math.floor(curmouseover))._x = Stage.width-eval("im"+Math.floor(curmouseover))._width; } else { //else the x position is set based on the distance from the centerpoint of that index eval("im"+Math.floor(curmouseover))._x = _xmouse-(curmouseover-Math.floor(curmouseover))eval("im"+Math.floor(curmouseover)).width; } //scale the image based on the image center's distance from x mouse position scale = Math.max(100, curvedistance-(Math.abs((eval("im"+Math.floor(curmouseover)).x+eval("im"+Math.floor(curmouseover)).width/2)-xmouse))/4); eval("im"+Math.floor(curmouseover)).xscale = scale; eval("im"+Math.floor(curmouseover)).yscale = scale; //Set the y position to the floor minus the height of the pic eval("im"+Math.floor(curmouseover)).y = floor-eval("im"+Math.floor(curmouseover)).imagemc.height*eval("im"+Math.floor(curmouseover)).yscale/100; //traverse through the images to the right of the current selected image, scaling and setting the x position for (curpos=Math.floor(curmouseover); curpos0; curpos--) { //scale the image based on the image center's distance from x mouse position scale = Math.max(100, curvedistance-(Math.abs((eval("im"+Math.floor(curpos-1)).x+eval("im"+Math.floor(curpos-1)).width/2)-xmouse))/4); eval("im"+Math.floor(curpos-1)).xscale = scale; eval("im"+Math.floor(curpos-1)).yscale = scale; //set the x position to the x position of the last image minus the width and sidegap eval("im"+Math.floor(curpos-1)).x = eval("im"+Math.floor(curpos)).x-(eval("im"+Math.floor(curpos-1)).width+sidegap); //move the y position according to how much the image is scaled eval("im"+Math.floor(curpos-1)).y = floor-eval("im"+Math.floor(curpos-1)).imagemc.height*eval("im"+Math.floor(curpos-1)).yscale/100; } } };

    XML file:

    1.jpg Video1 http://www.dancingbodies.co.uk/samples.html 2.jpg New York New York http://www.dancingbodies.co.uk/samples.html

    The flash works fine and when the user clicks on an image they are taken to the url. Please see: Link Text I just want to know how I can play a video file by looping through the images in the xml file and play a corresponding video.

    Any help would be be much appreciate.

    Post was edited on 21/07/2009 12:04:29 Report abuse

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Want to stay in touch with what's going on? Follow us on twitter!