Drag Interface
/**
* Copyright KRFX_ERRORISM ( http://wonderfl.net/user/KRFX_ERRORISM )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/hENL
*/
package {
import caurina.transitions.Tweener;
import flash.display.Graphics;
import flash.display.Sprite;
import flash.text.*;
import flash.events.*;
import net.hires.debug.Stats;
[SWF(width='400',height='300',frameRate='77',backgroundColor='0xcccccc')]
public class FlashTest extends Sprite {
private var sw:Number=200;
private var sh:Number=150;
private var s:Sprite;
private var sg:Graphics;
private var pages:int=5;
private var sgw:Number=sw*pages;
private var cx:Number;
private var px:Number=sgw/sw;
private var t:TextField;
private var tf:TextFormat=new TextFormat("_SANS",16,0x232323);
private var f:Boolean = false;
public function FlashTest():void {
init();
var stats:Stats = new Stats();
stats.x=10;
stats.y=200;
addChild(stats);
}
private function init():void {
s=new Sprite();
sg=s.graphics;
sg.beginFill(0xFFFFFF);
sg.drawRect(0,0,sgw,sh);
sg.endFill();
sg.lineStyle(0.5,0xFF0000,0.5);
for (var i:int=1; i<s.width/sw; i++) {
sg.moveTo(i*sw,0);
sg.lineTo(i*sw,sh);
}
for (var j:int=0; j<s.width/sw; j++) {
t=new TextField ;
t.defaultTextFormat=tf;
t.width=sw-40;
t.height=sh-20;
t.wordWrap=true;
t.selectable=false;
t.autoSize=TextFieldAutoSize.LEFT;
var n:int=j+1;
t.text=n.toString();
t.appendText(" Use Japanese letters for your variables new way of AS encryption");
t.x=j*sw+15;
t.y=25;
s.addChild(t);
}
addChild(s);
s.buttonMode = true;
s.mouseChildren = false;
s.addEventListener(MouseEvent.MOUSE_DOWN,md);
}
private function md(e:MouseEvent):void {
if(f){
Tweener.removeTweens(s,"x");
}
cx=s.mouseX;
stage.addEventListener(MouseEvent.MOUSE_UP,mu);
stage.addEventListener(MouseEvent.MOUSE_MOVE,mm);
f=true;
}
private function mu(e:MouseEvent):void {
stage.removeEventListener(MouseEvent.MOUSE_UP,mu);
stage.removeEventListener(MouseEvent.MOUSE_MOVE,mm);
tween();
}
private function mm(e:MouseEvent):void {
s.x=stage.mouseX-cx;
s.x > 0 ? s.x = 0 : null;
s.x < -s.width + stage.stageWidth ? s.x = -s.width+ stage.stageWidth : null;
e.updateAfterEvent();
}
private function tween():void {
Tweener.addTween(s,{x:Math.round(s.x/sw)*sw,time:0.4,transition:"easein"});
}
}
}