Drag, ease, add projection effect

Source: Internet
Author: User
Tags abs
Thanks to my brother, last night's help, hehe ~ ~ (Webstudio in a special effect production), interested, you can do it better ~ haha ... Occupy the place upload file, also share, hehe ~ reprint Please specify ~
Import Flash.filters.DropShadowFilter;
var filterropshadowfilter = new Dropshadowfilter (ten, 0x666666,. 6, 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;
}
};
Midnight and perfect the effect, and then add a dynamic projection down, the effect is completely out of the ~ can refer to the tutorial here:/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;



I wrote it in 3.0, and there's no events in 3.0. As Onreleaseoutside, Ondragout, OnDragOver and so on. therefore have to write their own events category, hehe ~ ~ Next study, and then discuss sharing.

/**
* ...
* @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];

}
}
}
Enter the forum and the author discuss the study

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.