Dynamic drag and edit of as3 text box and as3 text box

Source: Internet
Author: User

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.

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.