View Single Post
  #7 (permalink)  
Old 02-28-07, 10:40 AM
method method is offline
Wannabe Coder
 
Join Date: Jul 2006
Posts: 228
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by UnrealEd View Post
to be honest: i seriously have no idea: i've never worked with the jeroenwijering packages before.
If you tell me where i you add the images to the stack, i'llbe able to help (i couldn't find it in your fla).

What you have to do is find where and how you add the images to the stack, then place this in a function, which will be called every 15 secs. when you receive the data, you parse the xml, and then add the images to the ImageRotator stack

Also: when you read xml, you will have to parse it in flash first, otherwise you won't be able to grab the images in the xml. It's not that difficult to make if you stick with the parsing of the structure of your xml file.

UnrealEd

Thanks for your nice reply. I paste the link for the full package of this image rotator:

http://www.jeroenwijering.com/upload...ge_rotator.zip

The image urls are taken from an xml file . The xml file looks like this:


xml Code:
  1. <playlist version="1" xmlns="http://xspf.org/ns/0/">
  2.     <trackList>
  3.  
  4.         <track>
  5.             <title>Grass by Night</title>
  6.             <creator>Jeroen Wijering</creator>
  7.             <location>image1.jpg</location>
  8.             <info>http://www.jeroenwijering.com</info>
  9.         </track>
  10.  
  11.         <track>
  12.             <title>At the Sidewalk</title>
  13.             <creator>Jeroen Wijering</creator>
  14.             <location>image2.jpg</location>
  15.             <info>http://www.jeroenwijering.com</info>
  16.         </track>
  17.  
  18.         <track>
  19.             <title>Tio Pepe Madrid</title>
  20.             <creator>Jeroen Wijering</creator>
  21.             <location>image3.jpg</location>
  22.             <info>http://www.jeroenwijering.com</info>
  23.         </track>
  24.  
  25.     </trackList>
  26. </playlist>

The php code that pull xml and feed it to flash is like this:


PHP Code:

<?php

/*
You can use this script to pass-through a playlist from an external server to the players. 
Just insert the url to external playlist below and copy this file to your server.
You can use the flashvar "file=external_feed.php" in your HTML feed this script to the player.
*/


// build file headers
header("content-type:text/xml;charset=utf-8");
// refer to file
readfile("http://www.myserver.com/myplaylist.xml");
// that's all
exit();


?>
The parssing of xml file is done some where inside flash. I could not find it using flash 8 but i used flash decompilerd and i found some code i will paste it. Unfortunely i could not find these code using flash 8 trial!!I be happy if you look at it and tell me how to modify it:


ActionScript Code:
  1. // Action script...
  2.  
  3. // [Initial MovieClip Action of sprite 85]
  4. #initclip 1
  5. class com.jeroenwijering.players.AbstractPlayer
  6. {
  7.     var controller, fileArray, fileTypes, fileParser, parseArray;
  8.     function AbstractPlayer(tgt, fil)
  9.     {
  10.         configArray.playerclip = tgt;
  11.         configArray.playerclip._visible = false;
  12.         fil == undefined ? (null) : (configArray.file = fil);
  13.         this.loadConfig();
  14.     } // End of the function
  15.     function loadConfig()
  16.     {
  17.         configArray.width == "undefined" ? (configArray.width = Stage.width) : (null);
  18.         configArray.height == "undefined" ? (configArray.height = Stage.height) : (null);
  19.         for (var _loc3 in configArray)
  20.         {
  21.             _root&#91;_loc3] == undefined ? (null) : (configArray[_loc3] = unescape(_root[_loc3]));
  22.         } // end of for...in
  23.         configArray.displayheight == "undefined" ? (configArray.displayheight = configArray.height - 20) : (null);
  24.         if (configArray.fullscreenmode == "true")
  25.         {
  26.             var _loc4 = SharedObject.getLocal("com.jeroenwijering.players", "/");
  27.             configArray.file = _loc4.data.file;
  28.             configArray.captions = _loc4.data.captions;
  29.             configArray.fsreturnpage = _loc4.data.fsreturnpage;
  30.         } // end if
  31.         configArray.enablejs == "true" ? (this.enableLoadFile()) : (null);
  32.         this.loadFile(configArray.file);
  33.     } // End of the function
  34.     function loadFile(fil, tit, lnk, img, fid)
  35.     {
  36.         if (controller != undefined)
  37.         {
  38.             controller.getEvent("stop");
  39.             delete this.controller;
  40.         } // end if
  41.         configArray.file = fil;
  42.         tit == undefined ? (null) : (_root.title = tit);
  43.         lnk == undefined ? (null) : (_root.link = lnk);
  44.         img == undefined ? (null) : (_root.image = img);
  45.         fid == undefined ? (null) : (_root.id = fid);
  46.         fileArray = new Array();
  47.         var _loc4 = false;
  48.         for (var _loc6 in fileTypes)
  49.         {
  50.             if (fil.toLowerCase().indexOf(fileTypes&#91;_loc6].toLowerCase()) > -1)
  51.             {
  52.                 _loc4 = true;
  53.             } // end if
  54.         } // end of for...in
  55.         if (_loc4 == true)
  56.         {
  57.             fileArray&#91;0] = new Object();
  58.             fileArray&#91;0].file = fil;
  59.             for (var _loc5 in fileElements)
  60.             {
  61.                 _root&#91;_loc5] == undefined ? (null) : (fileArray[0][_loc5] = unescape(_root[_loc5]));
  62.             } // end of for...in
  63.             if (configArray.fullscreenmode == "true")
  64.             {
  65.                 var _loc7 = SharedObject.getLocal("com.jeroenwijering.players", "/");
  66.                 fileArray&#91;0].id = _loc7.data.id;
  67.             } // end if
  68.             configArray.playerclip._visible = true;
  69.             _root.activity._visible = false;
  70.             this.setupMCV();
  71.         }
  72.         else
  73.         {
  74.             var ref = this;
  75.             fileParser = new com.jeroenwijering.utils.FeedParser();
  76.             fileParser.onParseComplete = function ()
  77.             {
  78.                 ref.fileArray = parseArray;
  79.                 ref.configArray.playerclip._visible = true;
  80.                 _root.activity._visible = false;
  81.                 ref.setupMCV();
  82.             };
  83.             fileParser.parse(fil);
  84.         } // end else if
  85.     } // End of the function
  86.     function setupMCV()
  87.     {
  88.         controller = new com.jeroenwijering.players.AbstractController(configArray, fileArray);
  89.         var _loc5 = new com.jeroenwijering.players.AbstractView(controller, configArray, fileArray);
  90.         var _loc2 = new Array(_loc5);
  91.         var _loc3 = new com.jeroenwijering.players.AbstractModel(_loc2, controller, configArray, fileArray);
  92.         var _loc4 = new Array(_loc3);
  93.         controller.startMCV(_loc4);
  94.     } // End of the function
  95.     function enableLoadFile()
  96.     {
  97.         if (flash.external.ExternalInterface.available)
  98.         {
  99.             var _loc2 = flash.external.ExternalInterface.addCallback("loadFile", this, loadFile);
  100.         } // end if
  101.     } // End of the function
  102.     var configArray = {autoscroll: "", autostart: "", backcolor: "", bufferlength: "", callback: "", captions: "", displayheight: "", enablejs: "", file: "", frontcolor: "", fsreturnpage: "", fullscreenmode: "", fullscreenpage: "", height: "", lightcolor: "", linkfromdisplay: "", linktarget: "", logo: "", overstretch: "", playerclip: "", repeat: "", rotatetime: "", showdigits: "", showeq: "", showfsbutton: "", showicons: "", shownavigation: "", shuffle: "", streamscript: "", thumbsinplaylist: "", transition: "", volume: "", width: ""};
  103.     var fileElements = {title: "", author: "", link: "", image: "", id: "", category: "", start: ""};
  104. } // End of Class
  105. #endinitclip
  106.  

and :



ActionScript Code:
  1. // Action script...
  2.  
  3. // [Initial MovieClip Action of sprite 86]
  4. #initclip 2
  5. class com.jeroenwijering.utils.FeedParser
  6. {
  7.     var parseURL, parseArray, parseXML, firstChild;
  8.     function FeedParser()
  9.     {
  10.         RSS_TAGS.itunes:author = "author";
  11.         RSS_TAGS.geo:lat = "latitude";
  12.         RSS_TAGS.geo:long = "longitude";
  13.         ATOM_TAGS.geo:lat = "latitude";
  14.         ATOM_TAGS.geo:long = "longitude";
  15.     } // End of the function
  16.     function parse(url)
  17.     {
  18.         var ref = this;
  19.         parseURL = url;
  20.         parseArray = new Array();
  21.         parseXML = new XML();
  22.         parseXML.ignoreWhite = true;
  23.         parseXML.onLoad = function (success)
  24.         {
  25.             if (success)
  26.             {
  27.                 var _loc2 = firstChild.nodeName.toLowerCase();
  28.                 if (_loc2 == "rss")
  29.                 {
  30.                     ref.parseRSS();
  31.                 }
  32.                 else if (_loc2 == "feed")
  33.                 {
  34.                     ref.parseASF();
  35.                 }
  36.                 else if (_loc2 == "playlist")
  37.                 {
  38.                     ref.parseXSPF();
  39.                 }
  40.                 else
  41.                 {
  42.                     parseArray.push({title: "Feed not understood: " + ref.parseURL});
  43.                 } // end else if
  44.             }
  45.             else
  46.             {
  47.                 parseArray.push({title: "Feed not found: " + ref.parseURL});
  48.             } // end else if
  49.             parseArray.length == 0 ? (parseArray.push({title: "Empty feed: " + ref.parseURL})) : (null);
  50.             delete ref.parseXML;
  51.             ref.onParseComplete();
  52.         };
  53.         if (_root._url.indexOf("file://") > -1)
  54.         {
  55.             parseXML.load(parseURL);
  56.         }
  57.         else if (parseURL.indexOf("?") > -1)
  58.         {
  59.             parseXML.load(parseURL + "&" + random(999));
  60.         }
  61.         else
  62.         {
  63.             parseXML.load(parseURL + "?" + random(999));
  64.         } // end else if
  65.     } // End of the function
  66.     function parseRSS()
  67.     {
  68.         for (var _loc5 = parseXML.firstChild.firstChild.firstChild; _loc5 != null; _loc5 = _loc5.nextSibling)
  69.         {
  70.             if (_loc5.nodeName.toLowerCase() == "item")
  71.             {
  72.                 var _loc3 = new Object();
  73.                 for (var _loc6 = 0; _loc6 < _loc5.childNodes.length; ++_loc6)
  74.                 {
  75.                     var _loc2 = _loc5.childNodes&#91;_loc6];
  76.                     if (RSS_TAGS&#91;_loc2.nodeName.toLowerCase()] != undefined)
  77.                     {
  78.                         _loc3&#91;RSS_TAGS[_loc2.nodeName.toLowerCase()]] = _loc2.firstChild.nodeValue;
  79.                         continue;
  80.                     } // end if
  81.                     if (_loc2.nodeName.toLowerCase() == "description")
  82.                     {
  83.                         _loc3.description = com.jeroenwijering.utils.StringMagic.stripTagsBreaks(_loc2.firstChild.nodeValue);
  84.                         continue;
  85.                     } // end if
  86.                     if (_loc2.nodeName.toLowerCase() == "pubdate")
  87.                     {
  88.                         _loc3.date = com.jeroenwijering.utils.StringMagic.rfc2Date(_loc2.firstChild.nodeValue);
  89.                         continue;
  90.                     } // end if
  91.                     if (_loc2.nodeName.toLowerCase() == "dc:date")
  92.                     {
  93.                         _loc3.date = com.jeroenwijering.utils.StringMagic.iso2Date(_loc2.firstChild.nodeValue);
  94.                         continue;
  95.                     } // end if
  96.                     if (_loc2.nodeName.toLowerCase() == "media:thumbnail")
  97.                     {
  98.                         _loc3.image = _loc2.attributes.url;
  99.                         continue;
  100.                     } // end if
  101.                     if (_loc2.nodeName.toLowerCase() == "itunes:image")
  102.                     {
  103.                         _loc3.image = _loc2.attributes.href;
  104.                         continue;
  105.                     } // end if
  106.                     if ((_loc2.nodeName.toLowerCase() == "enclosure" || _loc2.nodeName.toLowerCase() == "media:content") && (_loc2.attributes.type == "audio/mpeg" || _loc2.attributes.type == "video/x-flv" || _loc2.attributes.type == "image/jpeg" || _loc2.attributes.type == "image/png" || _loc2.attributes.type == "image/gif"))
  107.                     {
  108.                         _loc3.file = _loc2.attributes.url;
  109.                         continue;
  110.                     } // end if
  111.                     if (_loc2.nodeName.toLowerCase() == "media:group")
  112.                     {
  113.                         for (var _loc4 = 0; _loc4 < _loc2.childNodes.length; ++_loc4)
  114.                         {
  115.                             _loc2.childNodes&#91;_loc4].attributes.type == "video/x-flv" ? (_loc3.file = _loc2.childNodes[_loc4].attributes.url) : (null);
  116.                             _loc2.childNodes&#91;_loc4].nodeName.toLowerCase() == "media:thumbnail" ? (_loc3.image = _loc2.childNodes[_loc4].attributes.url) : (null);
  117.                         } // end of for
  118.                     } // end if
  119.                 } // end of for
  120.                 if (_loc3.latitude == undefined && lat != undefined)
  121.                 {
  122.                     _loc3.latitude = lat;
  123.                     _loc3.longitude = lng;
  124.                 } // end if
  125.                 _loc3.image == undefined && _loc3.file.indexOf(".jpg") > 0 ? (_loc3.image = _loc3.file) : (null);
  126.                 _loc3.author == undefined ? (_loc3.author = ttl) : (null);
  127.                 parseArray.push(_loc3);
  128.                 continue;
  129.             } // end if
  130.             if (_loc5.nodeName == "title")
  131.             {
  132.                 var ttl = _loc5.firstChild.nodeValue;
  133.                 continue;
  134.             } // end if
  135.             if (_loc5.nodeName == "geo:lat")
  136.             {
  137.                 var lat = _loc5.firstChild.nodeValue;
  138.                 continue;
  139.             } // end if
  140.             if (_loc5.nodeName == "geo:long")
  141.             {
  142.                 var lng = _loc5.firstChild.nodeValue;
  143.             } // end if
  144.         } // end of for
  145.     } // End of the function
  146.     function parseASF()
  147.     {
  148.         for (var _loc5 = parseXML.firstChild.firstChild; _loc5 != null; _loc5 = _loc5.nextSibling)
  149.         {
  150.             if (_loc5.nodeName.toLowerCase() == "entry")
  151.             {
  152.                 var _loc3 = new Object();
  153.                 for (var _loc6 = 0; _loc6 < _loc5.childNodes.length; ++_loc6)
  154.                 {
  155.                     var _loc2 = _loc5.childNodes&#91;_loc6];
  156.                     if (ATOM_TAGS&#91;_loc2.nodeName.toLowerCase()] != undefined)
  157.                     {
  158.                         _loc3&#91;ATOM_TAGS[_loc2.nodeName.toLowerCase()]] = _loc2.firstChild.nodeValue;
  159.                         continue;
  160.                     } // end if
  161.                     if (_loc2.nodeName.toLowerCase() == "link" && _loc2.attributes.rel == "alternate")
  162.                     {
  163.                         _loc3.link = _loc2.attributes.href;
  164.                         continue;
  165.                     } // end if
  166.                     if (_loc2.nodeName.toLowerCase() == "summary")
  167.                     {
  168.                         _loc3.description = com.jeroenwijering.utils.StringMagic.stripTagsBreaks(_loc2.firstChild.nodeValue);
  169.                         continue;
  170.                     } // end if
  171.                     if (_loc2.nodeName.toLowerCase() == "published")
  172.                     {
  173.                         _loc3.date = com.jeroenwijering.utils.StringMagic.iso2Date(_loc2.firstChild.nodeValue);
  174.                         continue;
  175.                     } // end if
  176.                     if (_loc2.nodeName.toLowerCase() == "updated")
  177.                     {
  178.                         _loc3.date = com.jeroenwijering.utils.StringMagic.iso2Date(_loc2.firstChild.nodeValue);
  179.                         continue;
  180.                     } // end if
  181.                     if (_loc2.nodeName.toLowerCase() == "modified")
  182.                     {
  183.                         _loc3.date = com.jeroenwijering.utils.StringMagic.iso2Date(_loc2.firstChild.nodeValue);
  184.                         continue;
  185.                     } // end if
  186.                     if (_loc2.nodeName.toLowerCase() == "category")
  187.                     {
  188.                         _loc3.category = _loc2.attributes.term;
  189.                         continue;
  190.                     } // end if
  191.                     if (_loc2.nodeName.toLowerCase() == "author")
  192.                     {
  193.                         for (var _loc4 = 0; _loc4 < _loc2.childNodes.length; ++_loc4)
  194.                         {
  195.                             _loc2.childNodes&#91;_loc4].nodeName.toLowerCase() == "name" ? (_loc3.author = _loc2.childNodes[_loc4].firstChild.nodeValue) : (null);
  196.                         } // end of for
  197.                         continue;
  198.                     } // end if
  199.                     if (_loc2.nodeName.toLowerCase() == "link" && _loc2.attributes.rel == "enclosure" && (_loc2.attributes.type == "audio/mpeg" || _loc2.attributes.type == "video/x-flv" || _loc2.attributes.type == "image/jpeg" || _loc2.attributes.type == "image/png" || _loc2.attributes.type == "image/gif"))
  200.                     {
  201.                         _loc3.file = _loc2.attributes.href;
  202.                     } // end if
  203.                 } // end of for
  204.                 _loc3.author == undefined ? (_loc3.author = ttl) : (null);
  205.                 parseArray.push(_loc3);
  206.                 continue;
  207.             } // end if
  208.             if (_loc5.nodeName == "title")
  209.             {
  210.                 var ttl = _loc5.firstChild.nodeValue;
  211.             } // end if
  212.         } // end of for
  213.     } // End of the function
  214.     function parseXSPF()
  215.     {
  216.         for (var _loc6 = parseXML.firstChild.firstChild; _loc6 != null; _loc6 = _loc6.nextSibling)
  217.         {
  218.             if (_loc6.nodeName == "trackList")
  219.             {
  220.                 for (var _loc5 = 0; _loc5 < _loc6.childNodes.length; ++_loc5)
  221.                 {
  222.                     var _loc3 = new Object();
  223.                     for (var _loc4 = 0; _loc4 < _loc6.childNodes&#91;_loc5].childNodes.length; ++_loc4)
  224.                     {
  225.                         var _loc2 = _loc6.childNodes&#91;_loc5].childNodes[_loc4];
  226.                         if (XSPF_TAGS&#91;_loc2.nodeName.toLowerCase()] != undefined)
  227.                         {
  228.                             _loc3&#91;XSPF_TAGS[_loc2.nodeName.toLowerCase()]] = _loc2.firstChild.nodeValue;
  229.                             continue;
  230.                         } // end if
  231.                         if (_loc2.nodeName.toLowerCase() == "meta" && _loc2.attributes.rel == "http://www.jeroenwijering.com/start")
  232.                         {
  233.                             _loc3.start = _loc2.firstChild.nodeValue;
  234.                             continue;
  235.                         } // end if
  236.                         if (_loc2.nodeName.toLowerCase() == "annotation")
  237.                         {
  238.                             _loc3.description = com.jeroenwijering.utils.StringMagic.stripTagsBreaks(_loc2.firstChild.nodeValue);
  239.                         } // end if
  240.                     } // end of for
  241.                     parseArray.push(_loc3);
  242.                 } // end of for
  243.             } // end if
  244.         } // end of for
  245.     } // End of the function
  246.     function onParseComplete()
  247.     {
  248.     } // End of the function
  249.     var RSS_TAGS = {title: "title", author: "author", link: "link", guid: "id", category: "category"};
  250.     var ATOM_TAGS = {title: "title", id: "id"};
  251.     var XSPF_TAGS = {title: "title", creator: "author", info: "link", location: "file", image: "image", identifier: "id", album: "category"};
  252. } // End of Class
  253. #endinitclip
  254.  

Last edited by UnrealEd; 02-28-07 at 03:23 PM. Reason: plesae use the [highlight] and [php] wrappers when posting code
Reply With Quote