2010-01-15 110 views

回答

21

您可以使用作爲分隔符的字符串。但它們不可互換,即不能用撇號開始字符串,並用引號結束。

唯一的區別是你需要轉義哪些字符。在由引號分隔的字符串中,您需要轉義引號而不是撇號,反之亦然。

把文本He said "It's all right" and laughed.在一個字符串,你可以使用:

"He said \"It's all right\" and laughed." 

或:

'He said "It\'s all right" and laughed.' 
2

不,除了雙引號字符串更容易包含單引號,反之亦然。

3

號// *爲必填 - 至少15個字符

+0

這是我第一次看到編譯器永遠不會看的東西的評論。 ^^ – LoremIpsum 2011-12-18 09:02:42

3

沒有區別。

也就是說從ActionScript: The definitive Guide

String is the datatype used for textual data (letters, punctuation marks, and other characters). A string literal is any combination of characters enclosed in quotation marks: 

    "asdfksldfsdfeoif" // A frustrated string 
    "greetings"   // A friendly string 
    "[email protected]" // A self-promotional string 
    "123"    // It may look like a number, but it's a string 
    'singles'   // Single quotes are acceptable too 
0

在ActionScript本身,不會有差別,比未使用的分隔符的不可用性等轉義字符。上addEventListenerwill not work

在Flash Builder,公共AS3創作IDE針對Flex,自動完成兼容事件類型(例如,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

相關問題