一句话限制Flash中所有的动态文本输入框... -电脑资料

电脑资料 时间:2019-01-01 我要投稿
【www.unjs.com - 电脑资料】

    动态

刚开始的写法是:

    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中所有的动态文本输入框,

一句话限制Flash中所有的动态文本输入框...

电脑资料

一句话限制Flash中所有的动态文本输入框...》(https://www.unjs.com)。

    由此还可以类推。比如:

    MovieClip.prototype.onPress = startDrag;

    MovieClip.prototype.onRelease = stopDrag;

    MovieClip.prototype.onReleaseOutside = stopDrag;

这样Flash中所有的剪片剪辑都可以被拖拽了。

    :) enjoy!

最新文章