Advertisement

10.12.2008 at 07:05AM PDT, ID: 23807704
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.3

Flash xml Picture rotator Cache issue

Asked by gogetsome in ActionScript

Tags:

Hello, I'm using the code below for a flash picture rotator that uses an xml file that I create when the user lands on a particular page. Each page may have different images that will rotate in the rotator. My issue is cache on the client. The images do not change even though the xml file has different images then the initial xml file.  I'm trying to modify the original author's code for the rotator by changing the load method. I read that this is possible from another site. I have to admit that my flash skills are lacking and I need some help here.

Here is the actionscript. The error in on the load method.

How can I get this to work??

/****************************/
/* Crossfading slide show   */
/* Author: Todd Dominey     */
/* http://whatdoiknow.org   */
/* http://domineydesign.com */
/****************************/

// set random # variables - each must be 0 for first 'while' loop below
var randomNum = 0;
var randomNumLast = 0;

// parent container
var container_mc = this.createEmptyMovieClip("container",0);
// movie clip containers
container_mc.createEmptyMovieClip("loader1_mc",2);
container_mc.createEmptyMovieClip("loader2_mc",1);

// preload watcher
this.createEmptyMovieClip("watcher_mc",100);

// load xml
images_xml = new XML();
images_xml.ignoreWhite=true;
images_xml.onLoad = parse;
//images_xml.load("images.xml");
images_xml.load("images.xml?+Math.random());
//xml.load(xmlFile.xml?+Math.random());
function parse(success) {
      if (success) {
            imageArray = new Array();
            var root = this.firstChild;
            _global.numPause = Number(8 * 1000);
            _global.order = 'sequential';
            _global.looping = 'yes';
            _global.fadetime = 2;
            _global.xpos =0;
            _global.ypos = 0;
            var imageNode = root.lastChild;
            var s=0;
            while (imageNode.nodeName != null) {
                  imageData = new Object;
                  imageData.path = imageNode.attributes.path;
                  imageArray[s]=imageData;
                  imageNode = imageNode.previousSibling;
                  s++;
            }
            // place parent container
            container_mc._x = _global.xpos;
            container_mc._y = _global.ypos;
            // parse array
            imageArray.reverse();
            imageGen(imageArray);
      } else {
            trace('problem');
      }
}

// depth swapping
function swapPlace(clip,num) {
      eval(clip).swapDepths(eval("container_mc.loader"+num+"_mc"));
}

function loadImages(data,num) {
      if (i==undefined || i == 2) {
            i=2;
            createLoader(i,data,num);
            i=1;
      } else if (i==1) {
            createLoader(i,data,num);
            i=2;
      }
}
function createLoader(i,data,num) {
      thisLoader=eval("container_mc.loader"+i+"_mc");
      thisLoader._alpha=0;
      thisLoader.loadMovie(data[num].path);
      watcher_mc.onEnterFrame=function () {
            var picLoaded = thisLoader.getBytesLoaded();
            var picBytes = thisLoader.getBytesTotal();
            if (isNaN(picBytes) || picBytes < 4) {
                  return;
            }
            if (picLoaded / picBytes >= 1) {
                  swapPlace("container_mc.loader2_mc",1);
                  alphaTween = new mx.transitions.Tween(thisLoader, "_alpha", mx.transitions.easing.Regular.easeOut,0,100,_global.fadetime,true);
                  timerInterval = setInterval(imageGen,_global.numPause,data);
                  delete this.onEnterFrame;
            }
      }
}
function imageGen(data) {
      // random, or sequential?
      if (_global.order=="random") {
            // choose random # between 0 and total number of images
            while (randomNum == randomNumLast) {
                  randomNum = Math.floor(Math.random() * data.length);
                  trace(randomNum);
            }
            loadImages(data,randomNum);
            randomNumLast = randomNum;
      } else if (_global.order=="sequential") {
            // start at 0, increment to total number of images, then drop back to zero when done
            if (p==undefined || p==data.length && _global.looping=="yes") { p=0; } else { break; }
            loadImages(data,p);
            p++;
      } else {
            trace ("order attribute in xml isn't correct - must specify either 'random' or 'sequential'");
      }
      clearInterval(timerInterval);
}
stop();Start Free Trial
[+][-]10.13.2008 at 08:44AM PDT, ID: 22703398

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.13.2008 at 09:39AM PDT, ID: 22703846

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.13.2008 at 11:59AM PDT, ID: 22705166

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: ActionScript
Tags: flash actionscript
Sign Up Now!
Solution Provided By: blue-genie
Participating Experts: 1
Solution Grade: A
 
 
[+][-]10.13.2008 at 12:27PM PDT, ID: 22705470

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-44 - Hierarchy / EE_QW_2_20070628