+ -
当前位置:首页 → 问答吧 → 帮忙看看代码

帮忙看看代码

时间:2011-05-19

来源:互联网

Action Layer1内容

function galleryXml(linkUrl)
{
    System.useCodepage = true;
    img_name = new Array();
    img_link = new Array();
    thumb_image = new Array();
    galleryLink = new XML();
    galleryLink.ignoreWhite = true;
    galleryLink.load(linkUrl);
    galleryLink.onLoad = function (success)
    {
        if (success)
        {
            gotoAndStop(2);
            imgNum = galleryLink.firstChild.childNodes.length;
            for (var _loc2 = 0; _loc2 < imgNum; ++_loc2)
            {
                var _loc3 = this.firstChild.childNodes;
                img_name[_loc2] = _loc3[_loc2].childNodes[0].firstChild.nodeValue;
                img_link[_loc2] = _loc3[_loc2].childNodes[1].firstChild.nodeValue;
                thumb_image[_loc2] = _loc3[_loc2].childNodes[2].firstChild.nodeValue;
            } // end of for
            
        } // end if
    };
    var preLoaderCount = 0;
    pBar_mc.onEnterFrame = function ()
    {
        ++preLoaderCount;
        var _loc2 = Math.floor(galleryLink.getBytesLoaded() / galleryLink.getBytesTotal() * 100);
        if (!isNaN(_loc2))
        {
            if (_loc2 >= 100)
            {
                pBar_mc.play();
                this._alpha = this._alpha + 1.000000E-001 * -this._alpha;
                if (preLoaderCount == 30)
                {
                    this._visible = false;
                    delete this.onEnterFrame;
                } // end if
            } // end if
        } // end if
    };
} // End of the function
stop ();
linkUrl = "imglink.xml";
galleryXml(linkUrl);

Action Layer:帧2内容

function init() {
       playDirection = "left";
       imgSpeed = 4;
       rotateSpeed = 3500;
       centerX = Stage.width/2-180;
       centerY = Stage.height-350;
       this.createEmptyMovieClip("imgHolder", 1);
       imgHolder._x = centerX-470;
       imgHolder._y = centerY-80;
       imageWidth = 555;
       imageHeight = 330;
       targetAlpha = new Array();
       targetAlpha = [100, 100,  100];
       targetX = new Array();
       targetX = [centerX+10,centerX+150,  centerX+340];
       targetY = new Array();
       targetY = [centerY+80, centerY+50, centerY+80];
       getImageDepth = new Array();
       getImageDepth = [0, 200,  0];
       targetS = new Array();
       targetS = [80, 100,80];
       targetVisible = new Array();
       targetVisible = [true, true, true];
       leftBtn.swapDepths(3000);
       rightBtn.swapDepths(3001);
       disable_btn.swapDepths(3002);
       textVisible = new Array();
       textVisible = [false, false, false];
       totalNum = imgNum;
       indexNum = 1;
       disable_btn._visible = false;
       disable_btn._width = Stage.width;
       disable_btn._height = Stage.height;
       disable_btn.onRollOver = function() {
              this.useHandCursor = false;
              leftBtn.gotoAndStop(1);
              rightBtn.gotoAndStop(1);
       };
       for (var _loc3 = 0; _loc3<totalNum; ++_loc3) {
              imgHolder.attachMovie("img", "img"+_loc3, _loc3+10);
              var _loc2 = imgHolder["img"+_loc3];
              _loc2.no_txt.text = _loc3;
              _loc2._visible = false;
              _loc2._x = centerX;
              _loc2._xscale = 50;
              _loc2._yscale = 50;
              _loc2._alpha = 0;
              _loc2.no_txt.text = _loc3;
              _loc2.no_txt._visible = false;
              loadThumbs(thumb_image[_loc3], _loc2.thumbs);
              loadThumbs(thumb_image[_loc3], _loc2.thumbs2.th);
              _loc2.desc_txt.autoSize = true;
              _loc2.desc_txt.text = img_name[_loc3];
              _loc2.desc_txt.text = img_name[_loc3];
              _loc2.desc_txt._x = _loc2.desc_txt._x-_loc2.desc_txt.textWidth+10;
              _loc2.textBg._width = _loc2.desc_txt.textWidth+20;
              _loc2.textBg._x = _loc2.desc_txt._x-10;
              _loc2.desc_txt._visible = false;
              _loc2.textBg._visible = false;
       }
       // end of for
       imgHolder.img2.desc_txt._visible = true;
       imgHolder.img2.textBg._visible = true;
       imgHolder.img2.onRelease = function() {
              getURL(img_link[this._name.substr(3)]);
       };
       setMovie();
       diable_btn.swapDepths(210);
       diable_btn.onRollOver = function() {
              leftBtn.gotoAndStop(1);
              rightBtn.gotoAndStop(1);
              this.useHandCursor = false;
       };
}
// End of the function
function setMovie() {
       for (var _loc2 = 0; _loc2<totalNum; ++_loc2) {
              posNum = (indexNum+_loc2)%totalNum;
              var _loc1 = imgHolder["img"+_loc2];
              _loc1._visible = targetVisible[posNum];
              _loc1.desc_txt.autoSize = true;
              _loc1._x = targetX[posNum];
              _loc1._y = targetY[posNum];
              _loc1._xscale = targetS[posNum];
              _loc1._yscale = targetS[posNum];
              _loc1._alpha = targetAlpha[posNum];
              _loc1.swapDepths(getImageDepth[posNum]);
       }
       // end of for
}
// End of the function
function rotateMovie() {
       disable_btn._visible = true;
       for (var _loc3 = 0; _loc3<totalNum; ++_loc3) {
              posNum = (indexNum+_loc3)%totalNum;
              var _loc2 = imgHolder["img"+_loc3];
              _loc2._visible = false;
              _loc2._visible = targetX[posNum];
              _loc2.desc_txt._visible = textVisible[posNum];
              _loc2.textBg._visible = textVisible[posNum];
              if (textVisible[posNum] == true) {
                     _loc2.onRelease = function() {
                            getURL(img_link[this._name.substr(3)]);
                     };
              }
              // end if
              var _loc4 = new mx.transitions.Tween(_loc2, "_x", mx.transitions.easing.Back.easeOut, _loc2._x, targetX[posNum], imgSpeed, false);
              new mx.transitions.Tween(_loc2, "_y", mx.transitions.easing.Back.easeOut, _loc2._y, targetY[posNum], imgSpeed, false);
              new mx.transitions.Tween(_loc2, "_xscale", mx.transitions.easing.Back.easeOut, _loc2._xscale, targetS[posNum], imgSpeed, false);
              new mx.transitions.Tween(_loc2, "_yscale", mx.transitions.easing.Back.easeOut, _loc2._yscale, targetS[posNum], imgSpeed, false);
              new mx.transitions.Tween(_loc2, "_alpha", mx.transitions.easing.Back.easeOut, _loc2._alpha, targetAlpha[posNum], imgSpeed, false);
              _loc2.swapDepths(getImageDepth[posNum]);
              _loc4.onMotionFinished = function() {
                     disable_btn._visible = false;
              };
       }
       // end of for
}
// End of the function
function loadThumbs(linkUrl, movLoader) {
       var _loc3 = new MovieClipLoader();
       var _loc2 = new Object();
       _loc2.onLoadProgress = function(target, bytesLoaded, bytesTotal) {
              pctLoaded = Math.floor(bytesLoaded/bytesTotal*100);
              target._parent.pBar_mc.gotoAndPlay(2);
              if (!isNaN(pctLoaded)) {
                     if (pctLoaded>=100) {
                            target._parent.pBar_mc.gotoAndPlay(2);
                            this.gotoAndPlay(2);
                     }
                     // end if
              }
              // end if
       };
       _loc2.onLoadError = function(target_mc, errorCode, httpStatus) {
       };
       _loc2.onLoadInit = function(target) {
              new mx.transitions.Tween(target._parent.pBar_mc, "_alpha", mx.transitions.easing.Strong.easeOut, target._parent.pBar_mc._alpha, 30, 100, false);
              target._width = imageWidth;
              target._height = imageHeight;
       };
       _loc3.addListener(_loc2);
       _loc3.loadClip(linkUrl, movLoader);
}
// End of the function
function autoRotate() {
       leftBtn.gotoAndStop(1);
       rightBtn.gotoAndStop(1);
       if (playDirection == "right") {
              if (indexNum<totalNum) {
                     ++indexNum;
                     rotateMovie();
              }
              // end if
              if (indexNum == totalNum) {
                     indexNum = 0;
              }
              // end if
       }
       // end if
       if (playDirection == "left") {
              if (indexNum>0) {
                     --indexNum;
                     rotateMovie();
              }
              // end if
              if (indexNum == 0) {
                     indexNum = totalNum;
              }
              // end if
       }
       // end if
}
// End of the function
stop();
init();
rightBtn.onRelease = function() {
       if (indexNum<totalNum) {
              ++indexNum;
              rotateMovie();
       }
       // end if
       if (indexNum == totalNum) {
              indexNum = 0;
       }
       // end if
};
leftBtn.onRelease = function() {
       if (indexNum>0) {
              --indexNum;
              rotateMovie();
       }
       // end if
       if (indexNum == 0) {
              indexNum = totalNum;
       }
       // end if
};
leftBtn.onRollOver = function() {
       this.gotoAndStop(2);
       clearInterval(id);
};
rightBtn.onRollOver = function() {
       this.gotoAndStop(2);
       clearInterval(id);
};
rightBtn.onRollOut = function() {
       this.gotoAndStop(1);
       playDirection = this._name.substr(0, 5).toString();
       id = setInterval(autoRotate, rotateSpeed);
       trace(playDirection);
};
leftBtn.onRollOut = function() {
       this.gotoAndStop(1);
       playDirection = this._name.substr(0, 4).toString();
       id = setInterval(autoRotate, rotateSpeed);
       trace(playDirection);
};
id = setInterval(autoRotate, rotateSpeed);


imglk.xml内容

<?xml version="1.0" encoding="utf-8"?>
<URL>
<Image_Information>
              <img_name>名字1</img_name>
              <img_link>http://www.163.com</img_link>
              <thumb_image>image/1.png</thumb_image>
       </Image_Information>
<Image_Information>
              <img_name>名字2</img_name>
              <img_link>http://www.baidu.com</img_link>
              <thumb_image>image/2.png</thumb_image>
       </Image_Information>
<Image_Information>
              <img_name>名字3</img_name>
              <img_link>http://www.google.cn</img_link>
              <thumb_image>image/3.png</thumb_image>
       </Image_Information>
</URL>

问题,现在点击图片只链接最后一个链接地址

作者: pop2008   发布时间: 2011-05-19

楼主有点晕乎 能发源文件上来吗?

作者: liweing   发布时间: 2011-05-19

热门下载

更多