這種效果做法很多,網上到處可以搜出一大堆!
本例主要是應用了BitmapData類,仿制很容易。
做法:
處理一張首尾相接的環繞圖片,導入Flash庫中,打開庫,右擊圖片,選“鏈接”,“為ActionScript導出“,標識ID名為:pic
場景上什么也不放。最好將場景高度設為與圖片一樣高。寬度隨意,但要小于圖片寬度。
在第一幀粘帖如下代碼,即可測試:
import?flash.display.BitmapData;
import?flash.geom.*;
//從庫里取圖
var?picBD:BitmapData?=?BitmapData.loadBitmap("pic");
var?pic_mc:MovieClip?=?this.createEmptyMovieClip("pic_mc",?this.getNextHighestDepth());
pic_mc.attachBitmap(picBD,?this.getNextHighestDepth());
//創建用于“過渡”的圖
var?picBD2:BitmapData?=?new?BitmapData(Stage.width*2,?pic_mc._height,?false,?0xFF);
var?pic_mc2:MovieClip?=?this.createEmptyMovieClip("pic_mc2",?this.getNextHighestDepth());
pic_mc2.attachBitmap(picBD2,?this.getNextHighestDepth());
//截取源圖的前和后各一部分組成新的圖
picBD2.copyPixels(picBD,?new?Rectangle(0,?0,?Stage.width,?pic_mc._height),?new?Point(Stage.width,?0));
picBD2.copyPixels(picBD,?new?Rectangle(pic_mc._width-Stage.width,?0,?Stage.width,?pic_mc._height),?new?Point(0,?0));
//初始化位置
pic_mc2._x?=?pic_mc._x+pic_mc._width-Stage.width;
pic_mc2._y?=?pic_mc._y;
//計算兩個“常量”,以免下面的幀循環中反復計算
var?xa:Number?=?-(pic_mc._width-Stage.width)/2;
var?xb:Number?=?-(pic_mc2._width-Stage.width)/2;
var?v:Number?=5;//移動速度初值
this.onEnterFrame?=?function()?{
????????pic_mc._x?-=?v;
????????pic_mc2._x?-=?v;
????????//判斷不同位置下,pic_mc與pic_mc2有左右關系
????????if?(pic_mc._xxa?&&?pic_mc2._x>pic_mc._x)?{
????????????????pic_mc2._x?=?pic_mc._x-pic_mc2._width/2;
????????}?else?if?(pic_mc2._xxb?&&?pic_mc._x>pic_mc2._x)?{
????????????????pic_mc._x?=?pic_mc2._x-pic_mc._width+pic_mc2._width/2;
????????}
};
//鼠標移動,修調速度
this.onMouseMove?=?function()?{
????????v=Math.floor((this._xmouse-Stage.width/2)/30);//30為修調系數????????
}
附件上來了:
?

附件
:
BitmapData做環繞效果.swf

附件
:
BitmapData做環繞效果.fla
本文轉自:http://www.5uflash.com/flashjiaocheng/Flashaschengxu/625.html
更多文章、技術交流、商務合作、聯系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號聯系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元
