0 Replies Latest reply on Jan 15, 2010 11:00 PM by jimmydubdub

    SOLVED - FABridge - Type Coercion failed: cannot convert []@xxxxxxxx to (Actual class name)@xxxxxxx

    jimmydubdub

      Thought I'd post this in the hope of saving others the trouble I had.

       

      Summary


      Do not create a function named 'sort' in your actionscript class if you want it to work with FABridge.

       

      It would be great if someone from adobe could put this warning in the flex documentation.

       

      Detail

       

      Was getting this strange error when calling an object function.

       

      FABridge was able to create the object, but when passing it into a function that expected it as a parameter, it was showing the type coercion error. The name of the class it was converting from was blank.

       

      I was able to trace this back to the following code block in FABridge.js (In the 'serialize' function):


      if (t == "number" || t == "string" || t == "boolean" || t == null || t == undefined)
      {
           result = value;
      }
      else if (value instanceof Array || typeof(value.sort) == "function")
      {
           //arrays are serializesd recursively
           result = [];
           for (var i = 0; i < value.length; i++)
           {
                result[i] = this.serialize(value[i]);
           }
      }
      else if (t == "function")
      {

       

      Turns out I had a function named 'sort' declared in my actionscript class, which was causing FABridge to incorrectly treat it as an Array.

       

      Once I renamed this function, all was well.