日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 综合教程 >内容正文

综合教程

Flash AS3如何制作画框随图片的大小而动态改变

發(fā)布時間:2023/12/19 综合教程 31 生活家
生活随笔 收集整理的這篇文章主要介紹了 Flash AS3如何制作画框随图片的大小而动态改变 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

  這篇教程是向大家介紹Flash AS3制作畫框隨圖片的大小而動態(tài)改變方法,這是一個為圖片加框的效果,畫框依據(jù)圖片的大小而動態(tài)改變。

  1、新建一個Flash文件,寬、高設置為550*420,背景黑色。

  2、準備4張大小不同規(guī)格的圖片,最大的寬、高不要超過530*380。

  3、導入圖片:在文件菜單選導入=>導入到庫。  

  4、圖層1,改名為圖片。拖第一個圖片到舞臺將它轉(zhuǎn)換成影片剪輯。命名”Image 1 ″設定注冊點居中。  

  5、重復第4步,拖入其它的3張圖片到舞臺,任意擺放。命名”Image 2 ″,”Image 3 ″,”Image 4 ″,庫面板  

  6、給舞臺上的實例命名“image1”至“image4”。

  7、隱藏圖層1,添加圖層2。  

  8、圖層2改名為邊框,用矩形工具,填充色禁止,筆觸白色,高度為4像素,畫一個長方形邊框。

  9、將長方形轉(zhuǎn)換為影片剪輯,設置注冊點居中。舞臺實例命名為“imageBorder”。:  

  10、添加圖層3,命名為as,輸入代碼:

  復制代碼

  代碼如下:

  //Import TweenMax (we use it for animation)

  import gs.*;

  //Save the center coordinates of the stage

  var centerX:uint = stage.stageWidth / 2;

  var centerY:uint = stage.stageHeight / 2;

  //Let’s add the images to an array

  var imagesArray:Array = new Array(image1,image2,image3,image4);

  //This variable will store the current image displayed

  var currentImage:MovieClip = null;

  //Make the border invisible at first

  imageBorder.alpha = 0;

  //Loop through the array elements

  for (var i:uint = 0; i < imagesArray.length; i++) {

  //We want all the images to be invisible at the beginning

  imagesArray[i].alpha = 0;

  //Save the index of the image to a variable called "imageIndex"

  imagesArray[i].imageIndex = i;

  }

  //We listen when the user clicks the mouse on the stage

  stage.addEventListener(MouseEvent.CLICK, stageClicked);

  //This function is called when the user clicks the stage

  function stageClicked(e:MouseEvent):void {

  //Check that the current image is not null

  if (currentImage != null) {

  //Animate the current image away

  TweenMax.to(currentImage, 1, {alpha:0});

  //Check to see if we are at the end of the imagesArray

  if (currentImage.imageIndex == imagesArray.length - 1) {

  //Set the first image of the array to be our currentImage

  currentImage = imagesArray[0];

  } else {

  //We are not at the end of the array, so get the next image from the array

  currentImage = imagesArray[currentImage.imageIndex + 1];

  }

  } else {

  //If the currentImage is null (= we just started the movie), we set the first image in the array

  //to be our current image.

  currentImage = imagesArray[0];

  //Set the border’s alpha to 0.5

  imageBorder.alpha = 0.5;

  }

  //Position the current image and the border to the center of the stage

  currentImage.x = imageBorder.x = centerX;

  currentImage.y = imageBorder.y = centerY;

  //Animate the border’s width and height according to the current image’s dimensions.

  //We also a nice glow effect to the image border

  TweenMax.to(imageBorder, 0.5, {width: currentImage.width + 8, height: currentImage.height + 8,

  glowFilter:{color:Math.random() * 0xffffff, alpha:1, blurX:20, blurY:20, strength:100, quality:1}});

  //Animate the currentImage’s alpha

  TweenMax.to(currentImage, 1, {alpha:1});

  }

  11、全部完工,測試影片。注意:把gs類庫保存在fla同一目錄下。

  教程結(jié)束,以上就是Flash AS3制作畫框隨圖片的大小而動態(tài)改變教程,希望能對大家有所幫助,謝謝閱讀!

總結(jié)

以上是生活随笔為你收集整理的Flash AS3如何制作画框随图片的大小而动态改变的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。