在ActionScript中,单引号字符串和双引号字符串有什么区别吗?
He said "It's all right" and laughed.
放入一个字符串中,你可以使用:"He said \"It's all right\" and laughed."
或:'He said "It\'s all right" and laughed.'
编号。
// * 必填 - 至少15个字符
没有区别。
这段话来自于ActionScript权威指南:
字符串是用于文本数据(字母、标点符号和其他字符)的数据类型。字符串文字是由引号括起来的任何字符组合:
"asdfksldfsdfeoif" // A frustrated string
"greetings" // A friendly string
"moock@moock.org" // A self-promotional string
"123" // It may look like a number, but it's a string
'singles' // Single quotes are acceptable too
在Actionscript本身中,除了未使用的分隔符没有转义字符之外,没有其他区别。
在Flash Builder中,一个常见的AS3编写IDE用于Flex,在addEventListener
上自动完成兼容事件类型(例如Event.COMPLETE
)将不起作用,如果这些事件类型是用单引号而不是双引号定义的。
假设您有一个类,并使用Flex元标记将其标记为分派特定事件类型的标签。
[Event(name="foo",type="pkg.events.Constants")]
class SomethingThatDispatchesFoo extends EventDispatcher {
class Constants {
public static const FOO:String = 'foo';
}
然后自动完成将会给你'foo'
。但是,如果它的结构像这样:
class Constants {
public static const FOO:String = "foo";
}
自动完成将提供给您Constants.FOO
。