最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
拖动,缓动,加投影效果
时间:2022-07-02 17:15:34 编辑:袖梨 来源:一聚教程网
在此谢谢我师兄,昨晚的相助,呵呵~~ (webstudio 里的一个特效制作), 有兴趣的,可以一起把它做得更好~哈哈... 占用一下地方上传文件,也分享一下,呵呵~ 转载请注明~
import flash.filters.DropShadowFilter;
var filterropShadowFilter = new DropShadowFilter(10, 45, 0x666666, .6, 18, 18, 1, 3, false, false, false);
var filterArray:Array = new Array();
filterArray.push(filter);
var loop:Number;
var grav:Number;
function move() {
this._x += grav*(_root._xmouse-this._x)/loop;
this._y += grav*(_root._ymouse-this._y)/loop;
if (this._x+15 == _root._xmouse+15 || this._y+15 == _root._ymouse+15) {
//drag = false
group_mc.filters = null;
} else {
this.filters = filterArray;
}
//trace(grav)
//trace(loop)
}
var drag:Boolean = false;
group_mc.onPress = function() {
drag = true;
grav = .6;
loop = 1;
};
group_mc.onMouseMove = function() {
if (drag) {
grav = .1;
//loop = 10;
move.call(this);
}
};
group_mc.onRelease = group_mc.onReleaseOutside=function () {
drag = false;
//delete onEnterFrame;
};
group_mc.onEnterFrame = function() {
if (drag) {
move.call(this);
} else {
group_mc.filters = null;
}
};
var filterropShadowFilter = new DropShadowFilter(10, 45, 0x666666, .6, 18, 18, 1, 3, false, false, false);
var filterArray:Array = new Array();
filterArray.push(filter);
var loop:Number;
var grav:Number;
function move() {
this._x += grav*(_root._xmouse-this._x)/loop;
this._y += grav*(_root._ymouse-this._y)/loop;
if (this._x+15 == _root._xmouse+15 || this._y+15 == _root._ymouse+15) {
//drag = false
group_mc.filters = null;
} else {
this.filters = filterArray;
}
//trace(grav)
//trace(loop)
}
var drag:Boolean = false;
group_mc.onPress = function() {
drag = true;
grav = .6;
loop = 1;
};
group_mc.onMouseMove = function() {
if (drag) {
grav = .1;
//loop = 10;
move.call(this);
}
};
group_mc.onRelease = group_mc.onReleaseOutside=function () {
drag = false;
//delete onEnterFrame;
};
group_mc.onEnterFrame = function() {
if (drag) {
move.call(this);
} else {
group_mc.filters = null;
}
};
半夜又完善了一下效果,再加一个动态投影下去,效果就完全出来了~ 可以参考这里的教程: /tutorial/show.php?id=65
filter.blurY=filter.blurX = Math.abs((this._x-_root._xmouse)/3);
filter.distance=(this._x-_root._xmouse)/5;
this.filters = filterArray;
filter.distance=(this._x-_root._xmouse)/5;
this.filters = filterArray;
用3.0写了一遍,3.0里没有 events as onReleaseOutside, onDragOut, onDragOver and so on.所以得自己写events类,呵呵~~下次研究一下,再一起讨论共享.
/**
* ...
* @author lby
* @version 0.1
*/
package lbynet{
import flash.display.Sprite;
import flash.display.InteractiveObject;
import flash.events.MouseEvent;
import flash.events.Event;
import flash.filters.DropShadowFilter;
public class Drop {
private var loop:int;
private var grav:Number;
private var can:Boolean = false;
private var target:InteractiveObject;
private var stage:Sprite;
private var blurX:Number;
private var blurY:Number;
public function Drop(target:InteractiveObject,stage:Sprite) {
this.target = target;
this.stage = stage;
target.addEventListener(MouseEvent.MOUSE_DOWN,downHander);
target.addEventListener(MouseEvent.MOUSE_UP,upHander);
target.addEventListener(MouseEvent.MOUSE_MOVE,MoveHander);
//target.addEventListener(MouseEvent.MOUSE_OUT,OutHander);
target.addEventListener(Event.ENTER_FRAME,EnterFrameHander);
}
private function downHander(event:MouseEvent):void {
can = true;
grav = .6;
loop = 1;
trace("down");
}
private function upHander(event:MouseEvent):void {
can = false;
trace("UP");
}
private function MoveHander(event:MouseEvent):void {
if (can) {
grav = .1;
move();
}
}
private function OutHander(event:MouseEvent):void {
can = false;
}
private function EnterFrameHander(event:Event):void {
if (can) {
move();
} else {
target.filters = null;
}
}
private function move():void {
trace("move");
target.x += grav*(stage.mouseX - target.x)/loop;
target.y += grav*(stage.mouseY - target.y)/loop;
var filter:DropShadowFilter = new DropShadowFilter(10,45,0x666666,.6,blurX,blurY,1,3,false,false,false);
filter.blurX = filter.blurY = Math.abs((target.x-stage.mouseX)/3);
filter.distance = (target.x - stage.mouseX)/5;
target.filters = [filter];
}
}
}
进入论坛和作者讨论学习* ...
* @author lby
* @version 0.1
*/
package lbynet{
import flash.display.Sprite;
import flash.display.InteractiveObject;
import flash.events.MouseEvent;
import flash.events.Event;
import flash.filters.DropShadowFilter;
public class Drop {
private var loop:int;
private var grav:Number;
private var can:Boolean = false;
private var target:InteractiveObject;
private var stage:Sprite;
private var blurX:Number;
private var blurY:Number;
public function Drop(target:InteractiveObject,stage:Sprite) {
this.target = target;
this.stage = stage;
target.addEventListener(MouseEvent.MOUSE_DOWN,downHander);
target.addEventListener(MouseEvent.MOUSE_UP,upHander);
target.addEventListener(MouseEvent.MOUSE_MOVE,MoveHander);
//target.addEventListener(MouseEvent.MOUSE_OUT,OutHander);
target.addEventListener(Event.ENTER_FRAME,EnterFrameHander);
}
private function downHander(event:MouseEvent):void {
can = true;
grav = .6;
loop = 1;
trace("down");
}
private function upHander(event:MouseEvent):void {
can = false;
trace("UP");
}
private function MoveHander(event:MouseEvent):void {
if (can) {
grav = .1;
move();
}
}
private function OutHander(event:MouseEvent):void {
can = false;
}
private function EnterFrameHander(event:Event):void {
if (can) {
move();
} else {
target.filters = null;
}
}
private function move():void {
trace("move");
target.x += grav*(stage.mouseX - target.x)/loop;
target.y += grav*(stage.mouseY - target.y)/loop;
var filter:DropShadowFilter = new DropShadowFilter(10,45,0x666666,.6,blurX,blurY,1,3,false,false,false);
filter.blurX = filter.blurY = Math.abs((target.x-stage.mouseX)/3);
filter.distance = (target.x - stage.mouseX)/5;
target.filters = [filter];
}
}
}
相关文章
- 王者荣耀侦探能力大测试攻略 王者荣耀侦探能力大测试怎么过 11-22
- 无期迷途主线前瞻兑换码是什么 11-22
- 原神欧洛伦怎么培养 11-22
- 炉石传说网易云音乐联动怎么玩 11-22
- 永劫无间手游确幸转盘怎么样 11-22
- 无期迷途主线前瞻兑换码是什么 无期迷途主线前瞻直播兑换码介绍 11-22