Replace Function for ActionScript 2.0


function searchAndReplace(holder, searchfor, replacement) {
 temparray = holder.split(searchfor);
 holder = temparray.join(replacement);
 return (holder);
}

Do I need to say anything else ?

,

3 responses to “Replace Function for ActionScript 2.0”

  1. This function is not working for me.
    I used this function but its not replacing any character.
    Please check it :
    on(release)
    {
    var addr =searchAndReplace(txtAddress.text,”\n”,”|”);
    function searchAndReplace(holder, searchfor, replacement) {
    temparray = holder.split(searchfor);
    holder = temparray.join(replacement);
    return (holder);
    }
    }

  2. Did you try to trace txtAddress.text .. did it print anything?

    in flash at time you miss the scope. IF it trace then my next bet is that declare the function in your parent Movie clip of your button or atleast declare it just above the

    var addr=searchAndReplace(…); stuff.