| TextField:
可以获取的是onChanged和onScroller事件,我们结合昨天的部分程序写一个例子:
Movieclip.prototype.makeBox = function(x, y,
l) {
this.lineto(x, y+l);
this.lineto(x+l, y+l);
this.lineto(x+l, y);
this.lineto(x, y);
};
createEmptyMovieClip("scrollUp",3);
with (scrollUp) {
lineStyle(1,0x999999,50);
moveTo(550,200);
beginFill(0x345678,20);
makeBox(550,200,30);
endfill();
}
duplicateMovieClip(scrollUp, "scrolldown",
4);
scrollUp._y-=60;
scrollUp.onPress=function(){txt.scroll--};
scrollDown.onPress=function(){txt.scroll++};
createTextField("txt",5,300,10,100,40);
txt.border=1;
txt.wordwrap=1;
txt.multiline=1;
txt.type="input";
lsn5 = new Object();
lsn5.onScroller = function () {trace("text
scrolling") };
lsn5.onChanged = function () {trace("text
changed") };
txt.addListener(lsn5);
当文本超过最大长度的时候或者用户按下了scroll按钮的时候并且没有超过最高/最低scroll范围的时候取得onScroller响应;而用户输入文本的时候响应onChanged事件。
|