Actionscript的隐式强制转换行为是什么?

时间:2014-11-18 13:29:48

标签: actionscript-3 flash intellij-idea type-conversion flashdevelop

我自己是一名C ++ / C#程序员我现在不幸的是不得不在不久前由其他人写的更大的Actionscript / Air项目中实施一些更改。

使用" FlashDevelop"编译项目(或多或少)。作为IDE。但是出于其他原因,我们想要使用" IntelliJ"现在

事情是IntelliJ显然做了一些检查,现在吐出了几十个错误,如:

Error:(319, 0) [SomeSourceFile]: Implicit coercion of a value of type ByteArray to an unrelated type String.

在这样的代码上:

  public function send(ba:ByteArray):void{
                mdm.COMPort.send(ba)
            }

使用" mdm.COMPort.send"函数期待一个字符串。

是的,那就是类型不匹配错误!我完全同意!

但由于某种原因,它适用于旧项目。显然,Actionscript能够进行一些隐式类型转换/转换,并且没有检查类型安全性。

现在的问题:我该如何纠正? Actioncript在这种情况下应用的隐含行为是什么?

mdm.COMPort.send(ba.toString())
mdm.COMPort.send(string(ba))
mdm.COMPort.send(ba as string)
mdm.COMPort.send(ba.ReadUTFBytes(ba.length))

或其他我不知道的?

我现在在许多类型的地方确实遇到了这个问题(不仅是"字节数组"和"字符串"),所以一般的答案将不胜感激。

0 个答案:

没有答案
相关问题