Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flash 我想用(4x2)格式显示一个二次方程_Flash_Actionscript 3_Actionscript 2 - Fatal编程技术网

Flash 我想用(4x2)格式显示一个二次方程

Flash 我想用(4x2)格式显示一个二次方程,flash,actionscript-3,actionscript-2,Flash,Actionscript 3,Actionscript 2,我想用(4x2)格式显示一个二次方程。我想在文本框中键入x后自动将2显示为上标。Unicode提供上标数字 \u2070=⁰ \u00B9=imk \u00B2=² \u00B3=3 \u2074=⁴ \u2075=⁵ \u2076=⁶ \u2077=⁷ \u2078=⁸ \u2079=⁹ 因此,简单地用U+00B2替换上标的2 4x² - 2x + 4 下面是一些示例代码: private static const SUPER_DIGIT:Object = { '0':0x207

我想用(4x2)格式显示一个二次方程。我想在文本框中键入x后自动将2显示为上标。

Unicode提供上标数字

  • \u2070
    =⁰
  • \u00B9
    =imk
  • \u00B2
  • \u00B3
    =3
  • \u2074
    =⁴
  • \u2075
    =⁵
  • \u2076
    =⁶
  • \u2077
    =⁷
  • \u2078
    =⁸
  • \u2079
    =⁹
因此,简单地用U+00B2替换上标的2

4x² - 2x + 4
下面是一些示例代码:

private static const SUPER_DIGIT:Object = {
    '0':0x2070, '1':0x00B9, '2':0x00B2, '3':0x00B3, '4':0x2074, 
    '5':0x2075, '6':0x2076, '7':0x2077, '8':0x2078, '9':0x2079,
    '-':0x207B 
};

// Converts all 0123456789- characters to their superscript forms.
public static function toSuperscript(str:String):String {
    var buffer:Array = new Array(str.length);
    for (var i:int = 0; i < str.length; ++i) {
        buffer[i] = SUPER_DIGIT[str.charAt(i)];
        if (buffer[i] == null) buffer[i] = str.charCodeAt(i); 
    }
    return String.fromCharCode.apply(null, buffer);
}
私有静态常量超级数字:对象={
“0”:0x2070,“1”:0x00B9,“2”:0x00B2,“3”:0x00B3,“4”:0x2074,
'5':0x2075,'6':0x2076,'7':0x2077,'8':0x2078,'9':0x2079,
“-”:0x207B
};
//将所有0123456789字符转换为其上标形式。
公共静态函数toSuperscript(str:String):String{
变量缓冲区:数组=新数组(str.length);
对于(变量i:int=0;i
编辑:

如果您传递了我的方法
4x2
它将返回
⁴x²
。您需要做的是——在文本字段的更新事件中——检测需要转换为上标的子字符串并替换它们。一条对您有效的快速规则是:“如果一个数字紧跟在一个代码等于或大于‘A’(\u0041)的字符之后,请将其替换为上标等效字符。”

我不知道如何将代码与动态文本字段链接。你能提一下吗?@Pen:我在回答的末尾加了一个解释。