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

SQLite – compare null values

Hi,

this is a quick post describing issue I have found when using SQLite in flash. I’ve tried to fetch some rows using following snippet, but couldn’t get correct results. Then after digging on the net I have found that there is a different syntax to compare null values. The problem was in comparing values that sometimes can be null.

The idea was to get how many empty values I have in the database, the result was always 0. I have start with plain text query (no parameters), but it didn’t worked as I’ve found on the SQLite page you can’t just use equal to compare NULL values, you have special syntax IS NULL or IS NOT NULL.

Continue reading

StyleSheet’s method getStyle doesn’t return null for non-existing style

I have just learned that getStyle() method of flash.text.StyleSheet class doesn’t return null value when requested style doesn’t exists. Documentation states that it should, but in fact it returns empty object. Which could be fine for tests but you could have a style with empty declaration block which would create false positive result. This error appears to be for some time, check screen grabs from different players starting from fp9.
Continue reading

SQLite: Calculate difference between datetime fields

If you want to easily get elapsed time between datetime fields in SQLite you may want to take a look at following snippet:


SELECT
cast(
         (
                  strftime('%s',t.finish)-strftime('%s',t.start)
         ) AS real
      )/60/60 AS elapsed
FROM some_table AS t;


Table some_table contains 2 columns named start and finish both datetime type. Result will contain value in hours.

2nd Post From Flash!

And another sent from flash, I have used the metaWeblog.newPost(string blogid, string username, string password, struct content, bool publish)
Following is the structure passed as a third argument:

<struct>
   <member>
      <name>description</name>
      <value>This Post was generated, from the flash! 🙂 </value>
   </member>
   <member>
      <name>categories</name>
      <value>
         <array>
            <data>
               <value>flash</value>
               <value>xml-rpc</value>
         </data>
      </value>
   </member>
   <member>
      <name>dateCreated</name>
      <value>
         <dateTime.iso8601>20100822T02:50:00</dateTime.iso8601>
      </value>
   </member>
   <member>
      <name>title</name>
      <value>Post From Flash!</value>
   </member>
</struct>