Advertisement

06.25.2008 at 06:23AM PDT, ID: 23514334
[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.8

Continuous scrolling on resizable images

Asked by tiezinha in Macromedia Flash, ActionScript

Tags: ,

I have a image sequence, loaded inside a movieclipe through XML, that when i rollOver it the image grows.

What i want is to have these images scrolling continous, without any gap and without any mouse comand on the page, like: 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3...

The code i'm using makes it continous, but there's an anourmous gap between the end of the images and the beginning of it again.

Does anyone have any idea on how to clear the gap?

here's the code for the scrooling:

onClipEvent(enterFrame) {
  if(this._x<Stage.width) {
    this._x+=2;
  }else{
    this._x = 0-this._width;
  }
}

here's the code for loading the images trhoug XML:

      //Image Slider By John Bezanis for SWFspot
      //Settings to play with
      //the height of the images when not stretched
      var maxheight = 80;
      //the y position of the "floor" or where the images sit on
      var floor = 350;
      //The amount an image scales to as the mouse gets closer
      var curvedistance = 160;
      //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 = 0xFFFFFF;
      /*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<myXml.childNodes[0].childNodes.length; imageIndex++) {
          //create a new instance of imagebox to load our pic,caption,and url into
          attachMovie("imagebox", "im" + imageIndex, this.getNextHighestDepth());
          //load in the pic
          eval("im" + imageIndex).pic = myXml.childNodes[0].childNodes[imageIndex].childNodes[0].childNodes[0].nodeValue;
          //load the caption
          eval("im" + imageIndex).caption = myXml.childNodes[0].childNodes[imageIndex].childNodes[1].childNodes[0].nodeValue;
          //load the url
          eval("im" + imageIndex).url = myXml.childNodes[0].childNodes[imageIndex].childNodes[2].childNodes[0].nodeValue;
          //set the index to the current index of the for loop
          eval("im" + imageIndex).index = imageIndex;
          //move this above the caption box
          eval("im" + imageIndex).swapDepths(captionbox);
          //increment the imagecount
          imagecount++;
        }
      }
      //run at the start of each frame
      onEnterFrame = function () {
              //only run if the image have been loaded
        if (imagecount != 0) {
          //figure out which image the mouse is closest to on the x plane
          curmouseover = Math.max(0, Math.min(imagecount, imagecount*(_xmouse-sidegap)/(Stage.width-sidegap*2)));
          //if the current x position is greater than our strip's width, create a movieclip as a placeholder
          if (eval("im" + Math.floor(curmouseover))._x == undefined) {
            this.createEmptyMovieClip("im" + Math.floor(curmouseover), this.getNextHighestDepth());
            //Move the newly created clip to the width of the strip plus the sidegap
            eval("im" + Math.floor(curmouseover))._x = Stage.width+sidegap;
          }
         
          //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)).image_mc._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); curpos<imagecount-1; 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))._x+eval("im" + Math.floor(curpos))._width*1.5)-_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 plus the width and sidegap
            eval("im" + Math.floor(curpos+1))._x = eval("im" + Math.floor(curpos))._x+(eval("im" + Math.floor(curpos))._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)).image_mc._height*eval("im" + Math.floor(curpos+1))._yscale/100;
          }
          //traverse through the images to the left of the current selected image, scaling and setting the x position
          for (curpos=Math.floor(curmouseover); curpos>0; 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)).image_mc._height*eval("im" + Math.floor(curpos-1))._yscale/100;
         }
        }
      };



Thanks a lot.
Start Free Trial
[+][-]06.25.2008 at 07:28AM PDT, ID: 21865973

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 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.25.2008 at 07:37AM PDT, ID: 21866114

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 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.25.2008 at 08:30AM PDT, ID: 21866753

View this solution now by starting your 7-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

Zones: Macromedia Flash, ActionScript
Tags: actionscript, AS2
Sign Up Now!
Solution Provided By: aneeshchopra
Participating Experts: 1
Solution Grade: A
 
 
[+][-]06.25.2008 at 09:42AM PDT, ID: 21867556

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 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.25.2008 at 09:53AM PDT, ID: 21867639

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 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628