Reputation: 221
How do i make the path of the item and its name that is given within the "" into a simple string
what i mean is: when i just do this
var myText:String = new String("pathToImage")
trace(myText)
in the outPut window I get this : pathToImage.And that is Ok
But can i put double quotes into a string, like this
var myText:String = new String(" pathToImage("ImageName") ")
trace(myText)
and in the outPut window to get this : pathToImage("ImageName")
cause I'm trying this way, but it givems me an error:
1084: Syntax error: expecting rightparen before ImageName.
So is there a way of doing this?
Upvotes: 0
Views: 47
Reputation: 388183
First of all, it’s enough if you just use string literals. You do not need to call the String
constructor:
var myText:String = "pathToImage";
Second, string literals are either quoted with double quotes "
or single quotes '
. If you want the quotation character itself as a part of the string, you need to escape it using the escape character \
. So if you want to have a string pathToImage("ImageName")
, then you will have to do it like this:
var myText:String = "pathToImage(\"ImageName\")";
Alternatively, you can also use single quotes here. Using single quotes as the string delimiter allows you to use double quotes within the string without having to escape them. The same applies to single quotes within double-enquoted strings:
var myText:String = 'pathToImage("ImageName")';
Upvotes: 1