Dynamic drag and edit of as3 text box and as3 text box
Many software now supports text drag and drop on the editing interface and click Edit to directly modify the value, which is easy to operate and experience-oriented.
So I wrote it in as3 that I haven't written for a long time:
Because there is no prompt written by flash ide, no details will be processed for the moment. If it is used in the project, it will be a small problem, but this effect will not be affected.
Code:
import flash.text.TextField;import flash.events.*var txtDragValue:TextField;txtDragValue.selectable = false;var isDown:Boolean = false;var oldTxtValue:int = 0;var posXOld:int = 0;var isMoved:Boolean = false;function evt_down(e:Event){ isDown = true; isMoved = false; oldTxtValue = int(txtDragValue.text); posXOld = mouseX;}function evt_move(e:Event){ if(!isDown || txtDragValue.selectable)return; var tmpX:int = int(mouseX) if(posXOld!=tmpX){ isMoved = true; oldTxtValue+= (tmpX-posXOld)*1; posXOld = tmpX; txtDragValue.text = oldTxtValue.toString(); trace(oldTxtValue.toString()); }}function evt_up(e:Event){ isDown = false; if(!isMoved){ txtDragValue.selectable = true; txtDragValue.type = "input"; stage.focus=txtDragValue }}function evt_dea(e:Event){ if(!isMoved && txtDragValue.selectable){ txtDragValue.selectable = false; txtDragValue.type = "dynamic"; }}txtDragValue.addEventListener(MouseEvent.MOUSE_DOWN,evt_down);txtDragValue.addEventListener(MouseEvent.MOUSE_MOVE,evt_move);txtDragValue.addEventListener(MouseEvent.MOUSE_UP,evt_up);txtDragValue.addEventListener(FocusEvent.FOCUS_OUT,evt_dea);
Resource address:
Link: http://pan.baidu.com/s/1gd3wsRx password: 668g
Looking back at the use of such a variety of languages and engines, I feel that there is still room for development in flash, but adobe cannot help it. If there is as4, I hope to come to a c ++ version (it may be difficult to guess cross-platform). I feel that flash is still too scattered, because the software developed earlier has a wide range of uses, so that it can do everything, do nothing well, and write or find everything on its own, but fortunately, many of the engine such as tween-lite lightweight sports module and box2d-as3 version, can be very efficient support as3 this platform
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.