刚开始的写法是:
function limitToNum(){
if (this.text != "-" && isNaN(this.text)) {
this.text = '';
}
}
a_txt.onChanged = limitToNum;
b_txt.onChanged = limitToNum;
c_txt.onChanged = limitToNum;
...
发现有点繁琐,突然想起'prototype':
TextField.prototype.onChanged = function() {
if (this.text != "-" && isNaN(this.text)) {
this.text = '';
}
};
这样就限制了Flash中所有的动态文本输入框。

由此还可以类推。比如:
MovieClip.prototype.onPress = startDrag;
MovieClip.prototype.onRelease = stopDrag;
MovieClip.prototype.onReleaseOutside = stopDrag;
这样Flash中所有的剪片剪辑都可以被拖拽了。

:) enjoy!

 

posted on 2006-07-31 16:44  榻榻米  阅读(315)  评论(0编辑  收藏  举报