package{ImportFlash.display.Loader; ImportFlash.display.Sprite; Importflash.events.Event; Importflash.events.MouseEvent; Importflash.net.URLRequest; /** * @author frost.yen * @e-mail [email protected] * @create 2015-11-17 morning 10:20:30 **/[SWF (Width=" the", height=" the")] Public classEaseingeffectextendsSprite {Private var_ldr:loader =NewLoader (); Private var_container:sprite =NewSprite (); Private var_DOWNX: Number;//Press the x-coordinate of the photo wall Private var_movex: Number;//x-coordinate of moving photo wall Private var_OFFSETX: Number;//Move offset horizontally Private var_isdown:Boolean; Public functionEaseingeffect () {initviews (); Initeventlisteners (); } Private functionInitviews ():void { This. AddChild (_container); _container.addchild (_LDR); _ldr.load (NewURLRequest ("Assets/photowall.png")); } Private functionIniteventlisteners ():void{_ldr.contentloaderinfo.addeventlistener (event.complete,onloaded); _container.addeventlistener (Mouseevent.mouse_down, Ondown); This. AddEventListener (Event.enter_frame, onenterframe); } Private functionOnLoaded (e:event):void { } Private functionOndown (e:mouseevent):void{_isdown=true; _downx=MouseX; Stage.addeventlistener (Mouseevent.mouse_move, OnMove); Stage.addeventlistener (mouseevent.mouse_up, Onup); } Private functionOnenterframe (e:event):void{_offsetx= _offsetx * 0.900000; _container.x= _container.x +_offsetx; if(_container.x < 1920-_container.width) {_container.x= 1920-_container.width; } if(_container.x > 0) {_container.x= 0; } } Private functionOnMove (e:mouseevent):void { if(_isdown) {_movex=MouseX; _offsetx= _movex-_downx; _offsetx= _OFFSETX/20; } } Private functionOnup (e:mouseevent):void{_isdown=false; Stage.removeeventlistener (mouseevent.mouse_up, Onup); Stage.removeeventlistener (Mouseevent.mouse_move, OnMove); } }}
[ActionScript 3.0] AS3 One of the drag-and-drop mixing effects