鼠标双击实现文本框类型的转变。。

      flash学习 2005-5-10 13:53
广播事件:


//DBClick.as

import mx.events.EventDispatcher;
class DBClick extends MovieClip {
private var Dtime:Number = 200;
private var lastime:Number;
private var dispatchEvent:Function;
static var _f = EventDispatcher.initialize(DBClick.prototype);
public function DBClick() {
//...
}
private function Click(time:Number) {
if (lastime-(lastime=getTimer())+time>0) {
return true;
}
}
private function onMouseDown() {
if (Click(Dtime) and this.hitTest(_xmouse, _ymouse)) {
dispatchEvent({type:"dbclick", target:this});
}
}
}




//dbclick.fla

createEmptyMovieClip("temp_board", getNextHighestDepth());
temp_board.createTextField("test_txt", temp_board.getNextHighestDepth(), 100, 100, 100, 20);
with (temp_board.test_txt) {
type = "dymatic";
text = "abcdefg";
border = true;
selectable = false;
}
function changeType(txt:TextField, t:String, s:Boolean) {
with (txt) {
type = t;
selectable = s;
}
}
temp_board.__proto__ = DBClick.prototype;
var obj = {};
obj.dbclick = function(e:Object) {
trace("double");
(press=!press) ? changeType(temp_board.test_txt, "input", true) : changeType(temp_board.test_txt, "dymatic", false);
};
temp_board.addEventListener("dbclick", obj);




Flash 动画
标签集:TAGS:
回复Comments() 点击Count()

回复Comments

{commentauthor}
{commentauthor}
{commenttime}
{commentnum}
{commentcontent}
作者:
{commentrecontent}