Flash-Transparent时在FF和Safari下无法输入中文的解决方案
Learned from 《swfInputs: Solving Mozilla + Transparent Mode + Win + Special Chars within inputs》。
原来写过个日志《Flash在Safari下无法输入中文》,当时没有找到好的解决方案,现在在网上看到有这么个东西,swfInputs。
What to do in your code?具体代码的使用:
swfInputs consists of two parts(swfInputs包含2个部分):
* The SWFTextInput AS3 Class (which create the connection to the JavaScript class),一个AS3组件,负责Flash和JS的通信。
* and the swfInputs JavaScript Class (which handles the creation and HTML communication),一个JS文件,负责在HTML端建立Input。
To activate the JavaScript part you just need to insert two script-tags into the HTML code and call the constructor method. At the moment swfInputs uses the dojoToolkit JavaScript library for position calculation and basic connection handling. I looking forward to remove this need of dojo to reduce the filesize.
swfInputs使用dojoToolkit JS框架,恩,作者根据需求修正了dojoToolkit的尺寸。
<script src="../javascript/dojo.js" language="javascript"></script>
<script src="../javascript/swfInputs.js" language="javascript"></script>
<script language="JavaScript" type="text/javascript">
swfInputs.init('swfInputTestcase');
</script>
The String-value int the constructor call is the channel-name. This is optional if you just use on single instance within the HTML-page.
swfInputTestcase这个是HTML的标签名。
Within you Flash/ Flex application you have to use the SWFTextInput class for textfields instead of TextInput. The SWFTextInput class uses the JSCallStack to optimize the JavaScript communiaction ( which could be a lot on fast typing, so its recommanded to use it ).
A basic Flash/ Flex app could look like this. You see there is nothing very special instead of the swfInputs:SWFTextInput class.
Flash端代码示例:
<swfinputs :SWFTextInput id="swfInput01" borderColor="#ff0000" fontFamily="Verdana" />
只要使用swfInputs组件即可,Flash中如果使用TextField组件,可能需要修改部分代码。
这个东西的原理是这样的,swfInputs.js会在相应的swfInputs位置生成一个HTML的Input,然后获取用户输入数据后以ExternalInterface的方式传递给Flash。
原来在网上找解决方案的时候看到过这办法,不过没有人提供输入框位置的位置计算和字符串的传递方法。
现在有了这个东西,大家可以方便的解决这个问题了,嘿嘿~Good job Sebastian Martens!