3 Replies Latest reply on Oct 3, 2006 1:03 AM by Newsgroup_User

    vertexList in Javascript

    SingaporeGuy
      I'm trying to convert the following Lingo script to Javascript. I have a Javascript over 300 lines and don't want to convert it to Lingo. But I want the function here in Lingo, which works.

      "Vector" is a single diagonal line

      Lingo. (simplified version of script with basics in) this works fine.

      vlist = []
      vlist.add([#vertex:point(10,0)])
      vlist.add([#vertex:point(10,100)])
      member("Vector").vertexList=vlist


      == Javascript version. This gives an error on the last line (Script error:Wrong type)

      var vlist = propList();
      vlist.addProp(symbol("vertex"),point(10,0));
      vlist.addProp(symbol("vertex"),point(10,100));
      member("Vector").vertexList=vlist;


      How to get vertexList to work in javascript??
        • 1. Re: vertexList in Javascript
          Level 7
          > Lingo. (simplified version of script with basics in) this works fine.
          >
          > vlist = []
          > vlist.add([#vertex:point(10,0)])
          > vlist.add([#vertex:point(10,100)])
          > member("Vector").vertexList=vlist
          >
          >
          > == Javascript version. This gives an error on the last line (Script
          > error:Wrong type)
          >
          > var vlist = propList();
          > vlist.addProp(symbol("vertex"),point(10,0));
          > vlist.addProp(symbol("vertex"),point(10,100));
          > member("Vector").vertexList=vlist;

          Try:
          var vlist = list();
          vlist.append( propList(symbol("vertex"), point(10,0)) );
          vlist.append( propList(symbol("vertex"), point(10,100)) );
          member("Vector").vertexList=vlist;
          • 2. Re: vertexList in Javascript
            SingaporeGuy Level 1
            Thanks, but that doesn't work. .list() will not accept propList().
            vertexList wants a property list and list() isn't a property list, as far as understand.

            I've tried using linear lists as well as property lists. The most intutive way, to me, is the same at the Lingo script. But it doesn't work. It could be a bug in Javascript. I have found one before with using trace on lines.
            • 3. Re: vertexList in Javascript
              Level 7
              > Thanks, but that doesn't work. .list() will not accept propList().
              > vertexList wants a property list and list() isn't a property list, as far as
              > understand.

              No. A member's vertexList is a linear list (list()) of property lists
              (propList()). If you check the docs for 'vertexList' it starts with:
              "Cast member property; returns a linear list containing property lists"
              I tested what I posted in my message window and it looks correct. I
              didn't - at the time - try assigning it to a vector member. But when I
              did just now the vector member appeared fine.