我将字符串参数作为 FlashVars 传递到 Flex 应用程序中
参数有时包含特殊字符,除了 + 符号外,一切都显示正常,当它到达 flex 时,它会被空白替换。
这是例如的场景。
我在 JS 中有一个局部变量,它可以获取一些值,对于这个例子,它可以如下所示
<script language="JavaScript" type="text/javascript">
var testVar = "some_test_string_that_contains_+_character";
</script>
然后向我的 Flex 对象 AC_FL_RunContent 传递 "FlashVars","test="+testVar
在我编写的应用程序 Init 的 Flex 代码中
var testValue:String = application.parameters["testVar"].toString();
Alert.show(testValue);
现在显示正常,只是 + 字符被空白替换。对于/、@$-_ 等其他字符,不会发生这种情况,但 + 字符会发生这种情况。
任何与此相关的帮助将不胜感激。
最佳答案
来自Adobe's docs :
About flashVars properties encoding
The values of the flashVars properties must be URL encoded. The format of the string is a set of name-value pairs separated by an ampersand (&). You can escape special and nonprintable characters with a percent symbol (%) followed by a two-digit hexadecimal value. You can represent a single blank space using the plus sign (+).
进一步查看 matthew Horn 的评论之一,看起来您可以使用 %2B
来传递 +
字符。
关于apache-flex - 作为应用程序参数传递时,Flex + 字符被空白替换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5084628/