1 Reply Latest reply on Aug 17, 2009 7:48 AM by Yossi11

    Error in a simple example

    Yossi11

      Hi


      I'm trying to make a simple example working.
      The example was taken from director 11.5 scripting reference pdf.

      The code is in the function called BuildPolygons whithin a Movie Script.
      I also added a 3D window to the cast (menu Window/Shockwave 3D) and named it Shapes (Property Inspector/Member/Name:)

      I get an error message:
             Script Error: TypeError: nm.face[1] has no properties nm.face[1].vertices = [1,2,3];

      If I run it again, without Save & Compact,
      I get a different message:
          Script Error: Object with duplicate name already exists
              nm = member("Shapes").newMesh("Plane",1,3,0,3,0);

      As if the second run created another member called Shapes. (Shouldn't clear globals take care of it?)

       


      // The Movie script -
      //
      //----------------------------------------------------------------------------
      function startMovie()
      {
        clearGlobals();
        BuildPolygons();
      }
      //----------------------------------------------------------------------------

      function stopMovie()
      {
        clearGlobals();
      }
      //----------------------------------------------------------------------------

      function BuildPolygons()
      {
        nm = member("Shapes").newMesh("Plane",1,3,0,3,0);
        nm.vertexList = [vector(0,0,0), vector(20,0,0), vector(20, 20, 0)];
        nm.face[1].vertices = [1,2,3];
        nm.colorList = [rgb(255,255,0), rgb(0, 255, 0), rgb(0,0,255)];
        nm.face[1].colors = [3,2,1];
        nm.generateNormals("smooth");
        nm.build();
        nm = member("Shapes").newModel("TriModel", nm);
      }
      //----------------------------------------------------------------------------

       

      What am I doing wrong?
      Please help.