Xploit Xploit - 1 month ago 19
ActionScript Question

Actionscript 2 : Split() , Join()

My Question is how would i turn a string from this

"Hello"


to this

"H" + "e" + "l" + "l" + "o"


in Actionscript 2.. So far i've created 3 functions which after they are ran
my string returns as

H + e + l + l + o


The Problem im having is the letters arent considered Strings.. what can i do ?

Here is my code

function doURL(Link:String){
var Splitted:String = SplitURL(Link);
var Joined:String = JoinURL(Splitted);
var Product:String = Joined;
return Product;
}

function SplitURL(Link:String){
var SplitLink:Array = Link.split("");
var realLink:String = SplitLink;
return realLink;
}

function JoinURL(Split:Array){
var JoinLink:String = Split.join(" + ");
return JoinLink;
}


Im a little confused on how to add the extra quotations into the outcome

Answer

You can escape quotes in a string with backslash.

var s:String = "Hello";
var a:Array = s.split("");
trace("\"" + a.join("\" + \"") + "\"");

Result :

"H" + "e" + "l" + "l" + "o"