The String’s replace method and ArgumentError: Error #1063: Argument count mismatch error

Hi,

recently I have upgraded flash player (11.1.102.55), and suddenly found that one of my components was throwing following error:


ArgumentError: Error #1063: Argument count mismatch on Main/removeLinkStyleClass(). Expected 0, got 6.
at String$/_replace()
at String/http://adobe.com/AS3/2006/builtin::replace()
at Main/init()[...\bugs\string_replace\src\Main.as:27]
at Main()[...\bugs\string_replace\src\Main.as:16]

I was surprised as the code wasn’t changed and it was working earlier. When I have opened the problematic function I’ve noticed that it is the one used in replace function as the second parameter AS3 function replace(pattern:*, repl:Object):String. As I was creating this method following up the documentation I was using the arguments object, however after the flash player update this error appeared. At first I was lost with that, but then I’ve tried with …(rest) parameter, and it worked!

So if you will have the same problem try to modify your method to include the …(rest) parameter:

function replaceFunction(...args):String
{
//do what ever you need with args and return string
}

p.s. I will try to find the FP version when it started to be a problem, maybe it was announced?:)

best regards

This entry was posted in actionscript, bugs, flash and tagged , , , , , . Bookmark the permalink.

1 Response to The String’s replace method and ArgumentError: Error #1063: Argument count mismatch error

  1. Hi, Lukasz,

    I am facing same problem , i have 11.0.1.152 Plash player version

    Thanks for sharing Solution

Comments are closed.