There is no String#replace in Flash. If you are finding one, somebody has put one there for you. The typical kludge is:

String.prototype.replace = function (from, to) {
  return this.split(from).join(to);
}

Which is not accurate, since it obviously won't work with RegEx's. But then, there are no RegEx's in Flash either.

But it looks to me like what you really want is `encodeURIComponent`, which we make sure is available on all runtimes:

lzx> encodeURIComponent(LzCanvas.versionInfoString())
'URL%3A%20http%3A%2F%2Fdueling%2Dbanjos%2Elocal%3A8080%2Fdingdong %2Dclean%2Ftest%2Flpp%2D6066%2Elzx%3Flzt%3Dswf%26lzr%3Dswf8%0AVersion %3A%204%2E2%2Ex%2E0%0ARelease%3A%20Latest%0ABuild%3A%2010458%20%2FUsers %2Fptw%2FOpenLaszlo%2Fdingdong%2Dclean%0ADate%3A %202008%2D07%2D23T20%3A20%3A01%2D0400%0ATarget%3A%20swf8%0ARuntime%3A %209%2E124%0A'
lzx>

On 2008-07-23, at 19:35EDT, lcondellone wrote:

Its the same string both times, but maybe this will help:

_this code:_
var env_info = LzCanvas.versionInfoString();
Debug.write( env_info );
env_info = env_info.replace("\n", "; ");
env_info = env_info.replace("<![CDATA[&]]>", "; ");
var test = "test";
Debug.write('test: ', test.replace);

_Outputs this when working:_
URL: http://localhost:8080/main.lzx?lzt=swf&lzr=swf8&debug=true&lzbacktrace=true
Version: 4.0.11.0
Release: Mars Production
Build: 8460-openlaszlo-branches-pagan-deities
Date: 2008-03-28T07:37:32-0700
Target: swf8
Runtime: 9.124
test:  «Function#6| ../util/string-utils.js#15/59»

_And this when not:_
URL: http://localhost:8080/main.lzx?lzt=swf&lzr=swf8&debug=true&lzbacktrace=true
Version: 4.0.11.0
Release: Mars Production
Build: 8460-openlaszlo-branches-pagan-deities
Date: 2008-03-28T07:37:32-0700
Target: swf8
Runtime: 9.124
ERROR @LogService.lzx#55: call to undefined method 'replace'
ERROR @LogService.lzx#56: undefined object does not have a property 'replace'
WARNING @LogService.lzx#59: reference to undefined property 'replace'
test:  undefined

So is there added/missing functionality somewhere (this is a big project), or is String being manipulated? Can String be manipulated?

-LC


Henry Minsky wrote:
Is it possible you're not passing a string in those cases, but some
other object?
Is it reproducible? Maybe put a Debug.write(typeof(yourstringvar)) to
make sure.


On Wed, Jul 23, 2008 at 7:06 PM, lcondellone
<[EMAIL PROTECTED]> wrote:

Hi all,

When calling <some string>.replace("x", "y"), its sometimes works, and
sometimes I get "call to undefined method 'replace'".

There are also indicators that others have run into this problem: checks if
replace exists, comments that "String.replace is needed!"

Is this method disabled? Or how would one enable/disable it?

-LC










Reply via email to