Hiệu ứng chuột
(Tài liệu chưa được thẩm định)
Nguồn: NTP
Người gửi: Nguyễn Thanh Phong
Ngày gửi: 10h:28' 03-03-2012
Dung lượng: 6.8 KB
Số lượt tải: 0
Mô tả:
Nguồn: NTP
Người gửi: Nguyễn Thanh Phong
Ngày gửi: 10h:28' 03-03-2012
Dung lượng: 6.8 KB
Số lượt tải: 0
Mô tả:
/**
* Realistic Vertical Bitmap Smoke Effect
*
* Version: 1.0
* Author: Philip Radvan
* URL: http://www.freeactionscript.com
*/
//import bitmap class
import flash.display.BitmapData;
var currentBitmap:String = "smoke_clear.png";
/**
* doTrail - This function creates a smoke particle and sets all its parameters (settings)
*
* Params:
* container The container you want the particle to appear in. ex: _root or myContainer_mc
* targetX The x position of the particle
* targetY The y position of the particle
* type The type of particle you want to use. Named/attached directly from the library
*
**/
function doTrail(container:MovieClip, targetX:Number, targetY:Number, type:String):Void
{
//attach bitmap from the library with the linked name "adobe_flash"
var myBmp:BitmapData = BitmapData.loadBitmap(currentBitmap);
//create the "main_holder" movieclip that will hold our bitmap
var _particle = container.createEmptyMovieClip("main_holder"+container.getNextHighestDepth(), container.getNextHighestDepth());
//create an "internal_holder" movieclip inside "main_holder" that we'll use to center the bitmap data
var internal_holder:MovieClip = _particle.createEmptyMovieClip("internal_holder", _particle.getNextHighestDepth());
//set "internal_holder" x and y position based on bitmap size
internal_holder._x = -myBmp.width/2;
internal_holder._y = -myBmp.height/2;
//finally, attach the bitmapData "myBmp" to the movieclip "internal_holder"
internal_holder.attachBitmap(myBmp, internal_holder.getNextHighestDepth());
//set the particle's x & y position based on the target x & y. Offset the particle by a few pixels
_particle._x = targetX + random(4)-8;
_particle._y = targetY + random(4)-8;
//randomly rotate the particle 360 degrees
_particle._rotation = random(360);
//give the particle a random scale, between 50% and 100%
var randomScale = random(50)+50;
_particle._xscale = randomScale;
_particle._yscale = randomScale;
//give each particle its own speed
_particle.speed = random(5)+3;
//make it move
_particle.onEnterFrame = function ()
{
this._xscale += this.speed;
this._yscale += this.speed;
this._y -= this.speed;
this._alpha -= this.speed;
//check if particle is invisible, and remove it
if(this._alpha <= 0)
{
delete this.onEnterFrame;
removeMovieClip(this);
}
}
}
/**
* This onEnterFrame function adds a new particle every frame by executing doTrail
*
* For example, you could use it to give an enemy a smoke trail:
* doTrail(_root, myEnemy_mc._x, myEnemy_mc._y, "particle_smoke_black");
*
**/
_root.onEnterFrame = function():Void
{
doTrail(_root, _xmouse, _ymouse, currentBitmap);
}
/**
* Control Buttons
**/
one_btn.onRelease = function(){
currentBitmap = "smoke_black.png";
}
two_btn.onRelease = function(){
currentBitmap = "smoke_clear.png";
}
Nhấn vào đây để tải về
Nhắn tin cho tác giả
Báo tư liệu sai quy định
Xem toàn màn hình
Mở thư mục chứa tư liệu này
Nhắn tin cho tác giả
Báo tư liệu sai quy định
Xem toàn màn hình
Mở thư mục chứa tư liệu này
Số lượt thích:
0 người
 
Các ý kiến mới nhất