一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

as 3 flash图片切换代码

时间:2022-07-02 17:01:52 编辑:袖梨 来源:一聚教程网

代码如下:
stop();
var g_filters:GlowFilter=new GlowFilter(0xFFFFFF,1,3,3,5,BitmapFilterQuality.LOW);
var d_filters:DropShadowFilter = new DropShadowFilter(3, 45, 0x000000, 60, 8, 8);
var url_array:Array =[],btn_array:Array =[],myXML:XML = new XML(),j:uint=0,maskSprite:Sprite=new Sprite(),mySprite:Sprite=new Sprite(),title_txt:TextField=new TextField();
draw(maskSprite);
addChild(maskSprite);
maskSprite.x=stage.stageWidth/2-maskSprite.width/2;
maskSprite.y=stage.stageHeight/2-maskSprite.height/2;
function draw(sprite:Sprite,w:uint=400,h:uint=300 ,bgColor:uint=0xffff00 ):void {
  sprite.graphics.beginFill(bgColor);
  sprite.graphics.drawRect(0, 0, w, h);
  sprite.graphics.endFill();
}
title_txt.;
title_txt.x=150;
title_txt.y=280;
title_txt.autoSize=TextFieldAutoSize.CENTER;
addChild(mySprite);
mySprite.mask=maskSprite;
addChild(title_txt);
var XML_URL:String = "http://sxl001.xfyun.com/xmlImages.xml";
var myXMLURL:URLRequest = new URLRequest(XML_URL);
var myLoader:URLLoader = new URLLoader(myXMLURL);
myLoader.addEventListener("complete", xmlLoaded);
var xmlLong:uint;
function xmlLoaded(event:Event):void {
  myXML = XML(myLoader.data);
  xmlLong =myXML.child("image").length();
  for (var i:uint =0; i     url_array.push([myXML.image[i].@title,myXML.image[i].@url]);

  }
  event.target.removeEventListener("complete", xmlLoaded);
  init();
}

function init() {
  var loader:Loader = new Loader();
  loader.load(new URLRequest(url_array[j][1]));
  loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loadProgress);
  loader.contentLoaderInfo.addEventListener(Event.COMPLETE,loadComplete);
  function loadProgress(e:ProgressEvent):void {
    var percent:Number=Math.round(e.bytesLoaded/e.bytesTotal*10000)/100;
    title_txt.text=url_array[j][0]+" "+percent+" %";
    title_txt.filters=[g_filters];
    title_txt.mouseEnabled=false;
  }
  function loadComplete(event:Event):void {
    var loadBitmap:Loader=Loader(event.target.loader);
    var image:Bitmap=Bitmap(loadBitmap.content);
    image.x=j*400;
    image.;
    image.;
    mySprite.addChild(image);
    loader.contentLoaderInfo.removeEventListener(Event.COMPLETE,loadComplete);
    loader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, loadProgress);

    j++;
    if (j       mySprite.x=stage.stageWidth/2-j*400;
      mySprite.y=stage.stageHeight/2-mySprite.height/2;
      init();
    } else {

      title_txt.text=url_array[0][0];
      var myBg:bg=new bg();
      myBg.x=stage.stageWidth;
      myBg.y=stage.stageHeight;
      addChild(myBg);

      mySprite.x=0;
      mySprite.y=stage.stageHeight/2-mySprite.height/2;
      for (var i:uint=0; i         var myBtn:btn=new btn();
        myBtn.i=i;
        myBtn.t.text=""+uint(i+1);
        myBtn.mouseChildren=false;
        myBtn.x=stage.stageWidth-myBtn.width*(xmlLong-i);
        myBtn.y=stage.stageHeight-myBtn.height;
        btn_array.push(myBtn);
        addChild(myBtn);
        myBtn.addEventListener(MouseEvent.CLICK,onClick);
      }
    }
  }
}
var endX:uint;
function onClick(event:MouseEvent) {
  var mc:MovieClip=event.target as MovieClip;
  mc.m.gotoAndStop(2);
  for (var i:uint=0; i     var tempBtn:MovieClip=btn_array[i];
    if (tempBtn!=mc) {
      tempBtn.m.gotoAndStop(1);
    }
  }
  endX=int(mc.i)*400;
  mySprite.addEventListener(Event.ENTER_FRAME,onMove);
}
function onMove(event:Event) {
  var disx:Number =(endX-event.target.x)/12;
  event.target.x=disx;
  if (Math.abs(event.target.x+endX)<=5) {
    event.target.x=-endX;
    event.target.removeEventListener(Event.ENTER_FRAME,onMove);
  }
}

热门栏目