1 Reply Latest reply on Sep 7, 2006 7:46 AM by NormC_Mtl

    XML, FLVs and ActionScript

    phield Level 1
      Hello -- I am having a problem figuring out how to do something with Flash and XML, and am in kind of a bind (have been trying to figure out myself, and keep hitting a wall). Any assistance would be greatly appreciated, or please let me know what other info I need to provide.

      I am building a prototype video controller/selector to show low-res versions of videos created by my dept. The idea is to offer a list component of links to play videos in a video object. The list would be populated from an XML file. Also -- and this is where I am running into the most trouble -- I would like to take additional information from the XML file to fill in a three dynamic text boxes.

      I have on the stage a video object (instance name=myVideo), a list component (videoList), a play button (play_btn) and a pause button (pause_btn). Finally, I have a movieclip (info_mc), which holds 3 dynamic text boxes to display the selected videos title (title_txt), charge code (charge_txt), and a long description (longDesc_txt).

      Here is the XML (again, just a prototype, so pretty basic):

      <?xml version="1.0" encoding="ISO-8859-1"?>
      <video url="video1.flv" desc="First Video" title="The first video" charge="ABC123" longdesc="This is a video that we created a while back" />
      <video url="video2.flv" desc="Second Video" title="The second video" charge="ABC124" longdesc="This is another video" />
      <video url="video3.flv" desc="Third Video" title="The third video" charge="ABC125" longdesc="This is "This is another video" />
      <video url="video4.flv" desc="Fourth Video" title="The fourth video" charge="ABC126" longdesc="This is "This is another video" />
      <video url="video5.flv" desc="Fifth Video" title="The fifth video" charge="ABC127" longdesc="This is "This is another video" />

      Here is the AS in my prototype:

      var nc:NetConnection = new NetConnection();
      var ns:NetStream = new NetStream(nc);

      play_btn.onRelease = function() {
      pause_btn.onRelease=function() {

      var vlist:XML = new XML();
      vlist.ignoreWhite = true;
      vlist.onLoad = function() {
      var videos:Array = this.firstChild.childNodes;
      for(i=0;i<videos.length;i++) {
      videoList.addItem(videos .attributes.desc,videos.attributes.url);
      videoList.selectedIndex = 0;
      var vidList:Object = new Object();
      vidList.change = function() {

      The video list component works pretty well. I cannot for the life of me figure out how to get additional attributes from the XML file to appear in the 3 dynamic text boxes. Can anyone help me?

      Also, should these 3 additional pieces of information (title, charge, and long description) appear as additional attributes of the video element in the XML file (as shown above), or is it better to add additional elements within the <video> element for <title>, <charge>, and <longdesc>? Once there, how do I get this info to appear in the text boxes, and change depending upon the video that is selected?

      Thanks very much. If any additional info is needed, please let me know. THANKS!!
        • 1. Re: XML, FLVs and ActionScript
          NormC_Mtl Level 1
          I recently had to do something similar, and this is what I came up with:

          Below is the contents of the XML file and the actionScript to load and parse it.
          The actionScript creates an array containing 3 items. Each item is an object that has 3 attributes (vidpath, otherAttribute, description). description is the text in each element, e.g., Text description 1.