打印

[应用] 相册相关

看一下午没整明白哪控制这个点下一张图片后上一张图片过渡的效果是在哪里改的...点下一张后,上一张就向下挪出屏幕了...我想换种方法...但不知道怎么改....几部元件我看没有这个.应该是在代码里实现的..哪位大侠帮小弟指点一下...先谢谢了
第一层第一帧代码:
stop();
uniqueBounceID = 0;
function bounce(param, endingVal, clipName, speedFactor, bounceFactor) {
       //Do not run if the clipName does not exist
       if (clipName<>false) {
              //Clear old setIntervals with same param name that might still be firing - prevents the clipName movie from being caught between two different parameter values
              clearInterval(_root["bounceInterval"+clipName[param+"ID"]]);
              //Reassign variables to make them private variables of the movie clip
              var bounceID = _root.uniqueBounceID++;
              clipName["param"+bounceID] = param;
              clipName["endingVal"+bounceID] = endingVal;
              clipName["speedFactor"+bounceID] = speedFactor;
              clipName["bounceFactor"+bounceID] = bounceFactor;
              clipName["startingParamVal"+bounceID] = clipName[param];
              clipName["changedParamVal"+bounceID] = 0;
              //Store the bounceID for this parameter into a variable in the clipName movieclip - used to clear the setInterval if the movie clip is removed before the function completes
              clipName[param+"ID"] = bounceID;
              //Bounce function called from the setInterval
              clipName["callBounce"+bounceID] = function () {
                     //If the clip no longer exists, clear the setInterval         
                     if (clipName._x == undefined) {
                            clearInterval(_root["bounceInterval"+bounceID]);
                     } else {
                            // Don't fire if the destination position is met   
                            if (clipName["endingVal"+bounceID]<>Math.round(clipName[clipName["param"+bounceID]])) {
                                   // Modify the changedParamVal by using a simple friction equation
                                   clipName["changedParamVal"+bounceID] = clipName["changedParamVal"+bounceID]*clipName["bounceFactor"+bounceID]+(clipName["endingVal"+bounceID]-clipName["startingParamVal"+bounceID])/clipName["speedFactor"+bounceID];
                                   // Increment the startingParamVal by the new changedParamVal
                                   clipName["startingParamVal"+bounceID] += clipName["changedParamVal"+bounceID];
                                   // Snaps bouncing object to the pixel to reduce blinking effect and keep fonts pixelized
                                   clipName[clipName["param"+bounceID]] = Math.round(clipName["startingParamVal"+bounceID]);
                            } else {
                                   //Ensure final destination
                                   clipName[clipName["param"+bounceID]] = clipName["endingVal"+bounceID];
                                   // Clear the setIntervaly
                                   clearInterval(_root["bounceInterval"+bounceID]);
                            }
                     }
                     //trace(clipName+" "+bounceID+":"+clipName["param"+bounceID]+" = "+clipName[clipName["param"+bounceID]]);
              };
              //Call the bounce function 100 times per second
              _root["bounceInterval"+bounceID] = setInterval(clipName["callBounce"+bounceID], 10);
       }
}

第2层第1帧代码:
this.importXML = new XML();
this.importXML.ignoreWhite = true;
this.importXML.onLoad = function(success) {
       if (success) {
              // pointer to the root node
              var root = this.firstChild;
              // fill in the multi-dimensional menu array
              menuA = new Array();
              for (var i = root.firstChild; i != null; i=i.nextSibling) {
                     menuA[menuA.length] = [i.attributes.name, i.attributes.image];
              }
              //Once the XML is loaded, build the bottom menu
              buildMenu();
       } else {
              trace("ERROR loading xml");
       }
};
this.importXML.load("gallery.xml");

第3帧第一行代码:
menuBack._visible = false;
menuNext._visible = false;
//Functions to build the bottom menu
function buildMenu() {
       //Create a photoMenu movie clip to hold the menu items
       this.createEmptyMovieClip("photoMenu", this.getNextHighestDepth());
       //position the photoMenu
       photoMenu._x = 160;
       photoMenu._y = 370;
       //Attach the photoMenu mask
       this.createEmptyMovieClip("photoMenuMask", this.getNextHighestDepth());
       photoMenuMask.attachMovie("menuMask", "menuMask", this.getNextHighestDepth());
       //position the photoMenuMask
       photoMenuMask._x = 160;
       photoMenuMask._y = 370;
       //Apply the mask
       photoMenu.setMask(photoMenuMask);
       //The number of menu elements in the menuA array
       menuLength = menuA.length;
       //If there are less than 7 menu items, set photoMenu._x to center all elements
       if (menuLength<7) {
              // Position in center (450 is the center of this swf)
              photoMenu._x = Math.round(450-(menuLength*97)/2);
       } else {
              recordNumber = 1;
              //If there are more than 7 menu items, set the records text and turn on the controls
              records.text = recordNumber+" - "+(recordNumber+5)+" of "+menuLength+" photos";
              menuBack._visible = true;
              menuNext._visible = true;
              //Set the menuX variable that the buttons Move buttons use to position the photoMenu movie clip
              menuX = photoMenu._x;
       }
       //Spacer between elements
       menuSpacer = 7;
       //Starting x for each element
       startX = 0;
       //Build the bottom menu
       for (var i = 0; i<menuLength; i++) {
              //attach an element for each menu item
              photoMenu.attachMovie("element", "e"+i, i);
              e = photoMenu["e"+i];
              e.name = menuA[i][0];
              e.image = menuA[i][1];
              e.alreadyViewed = 0;
              e.thumbnail.loadMovie("photos/"+e.image+"_thumb.jpg");
              e._x = startX;
              startX += e._width+menuSpacer;
              e.onRollOver = function() {
                     bounce("_alpha", 0, this.menuOver, 5, 0);
                     _root.playOverSound();
              };
              e.onRollOut = function() {
                     bounce("_alpha", 60, this.menuOver, 10, 0);
              };
              e.onPress = function() {
                     //Call the new photo and info
                     changePhoto(this.name, this.image);
                     //Display viewed if needed
                     if (this.alreadyViewed == 0) {
                            this.viewed.gotoAndPlay(2);
                     }
                     this.alreadyViewed = 1;
              };
              //When the last menu element is added, display the first photo
              if (i == (menuLength-1)) {
                     //Set initial record number and counter
                     recordNumber = 1;
                     // Display the first photo in the set
                     name = menuA[0][0];
                     image = menuA[0][1];
                     photoTitle.autoSize = "left";
                     changePhoto(name, image);
              }
       }
}
//Set photoNum to 0 at start
photoNum = 0;
// Change Photo function
function changePhoto(name, image) {
       photoTitle.text = "";
       //Store the image name to be read into the new photo
       currentPhoto = image;
       photoName = name;
       //Simulate the previous photo falling off the screen (460 is off the bottom of this swf)
       bounce("_rotation", 15, this["photo"+photoNum], 5, 0);
       bounce("_y", 460, this["photo"+photoNum], 8, 0);
       bounce("_alpha", 30, this["photo"+photoNum], 8, 0);
       photoNum++;
       this.createEmptyMovieClip("photo"+photoNum, getNextHighestDepth());
       this["photo"+photoNum].attachMovie("photo", "photo", getNextHighestDepth());
       //remove old photos
       oldPhoto = this["photo"+(photoNum-2)];
       oldPhoto.removeMovieClip();
       //***** The positioning script is located within the photo movie clip
}
stop();