Why is this not working anymore?[FIXED]

I followed Todd's tutorials, and now I updated to the new box2d I'm getting several errors since some classess are changed or even removed like b2PolygonShapeDef.
I have spent quite some time on trying to convert it myself, but I haven't managed to fix it. And the outdated documentation didn't really help either.

The class creates box2d shapes based on given points.
Here's the code that made the magic happen in box 2.0:
Code:
package Actors
{
   //Import Libraries
   import Box2D.Collision.Shapes.*;
   import Box2D.Dynamics.*;
   import Box2D.Common.Math.b2Vec2;
   import flash.display.DisplayObjectContainer;
   import flash.display.Sprite;
   import flash.geom.Point;
   
   /**
    * ...
    * @author Jason Gidding
    */
   
   //Arbitrary Static Actor Class
   public class ArbiStaticActor extends Actor
   {
      //Constructor
      public function ArbiStaticActor(parent:DisplayObjectContainer, location:Point, arrayOfCoords:Array, costumeVisible:Boolean) {
         //Link my body with parameters
         var myBody:b2Body = CreateBodyFromCoords(arrayOfCoords, location);
         
         //Create sprite
         if (costumeVisible) {
            var myCostume:Sprite = CreateSpriteFromCoords(arrayOfCoords, location, parent);
         } else {
            myCostume = new Sprite();
         }
         
         //Costume's visibility is set to passed on property
         myCostume.visible = costumeVisible;
         
         //Pass on my body and costume to my parent
         super(myBody, myCostume);
      }
      
      //Create Sprite From Coordinates
      private function CreateSpriteFromCoords(arrayOfCoords:Array, location:Point, parent:DisplayObjectContainer):Sprite {
         //Create new Sprite
         var newSprite:Sprite = new Sprite();
         
         //Create lineStyle
         newSprite.graphics.lineStyle(2, 0x00C60F);
         
         //For each listOfPoints in arrayOfCoords
         for each (var listOfPoints:Array in arrayOfCoords) {
            //Set firstPoint
            var firstPoint:Point = listOfPoints[0];
            
            //Draw line to firstPoint x, y
            newSprite.graphics.moveTo(firstPoint.x, firstPoint.y);
            
            //With green color
            newSprite.graphics.beginFill(0x00C60F);
            
            //For each newPoint in listOfPoints
            for each (var newPoint:Point in listOfPoints)
            {
               //Set line to newPoint x, y
               newSprite.graphics.lineTo(newPoint.x, newPoint.y);
            }
            
            //Draw lineTo firstPoint x, y
            newSprite.graphics.lineTo(firstPoint.x, firstPoint.y);
            newSprite.graphics.endFill();
         }
         
         //Place newSprite to location x, y
         newSprite.x = location.x;
         newSprite.y = location.y;
         
         //Add newSprite to the parent
         parent.addChild(newSprite);
         
         //Return new sprite
         return newSprite;
      }
      
      //Create Body From Coordinates
      private function CreateBodyFromCoords(arrayofCoords:Array, location:Point):b2Body {
         //Define Shapes
         var allShapeDefs:Array = [];
         
         //Go through each list of points in arrayofCoords
         for each (var listOfPoints:Array in arrayofCoords) {
            //Create new b2PolyGondDef shapes
            var newShapeDef:b2PolygonDef = new b2PolygonDef();
            
            //Set vertex count to the listofPoints length
            newShapeDef.vertexCount = listOfPoints.length;
            
            //Go through the listofPoints length
            for (var i:int = 0; i < listOfPoints.length; i++)
            {
               //Set nextPoint to the listofPoints index
               var nextPoint:Point = listOfPoints[i];
               
               //Set vertexes to each point
               b2Vec2(newShapeDef.vertices[i].Set(nextPoint.x / gameData.RATIO, nextPoint.y / gameData.RATIO));
            }
            
            //Set bounce, slide, and material
            newShapeDef.density = 0;
            newShapeDef.friction = 0.0;
            newShapeDef.restitution = 0;
            
            //Push newShapeDef into the allShapeDefs array
            allShapeDefs.push(newShapeDef);
         }
         
         //Define a body
         var arbiBodyDef:b2BodyDef = new b2BodyDef();
         arbiBodyDef.position.Set(location.x / gameData.RATIO, location.y / gameData.RATIO);
         
         //Create the body
         var arbiBody:b2Body = gameData.world.CreateBody(arbiBodyDef);
         
         //Go through each new ShapeDef in allShapeDefs
         for each (var newShapeDefToAdd:b2ShapeDef in allShapeDefs)
         {
            //Create the shape
            arbiBody.CreateShape(newShapeDefToAdd);
         }
         
         //Set Mass from Shapes
         arbiBody.SetMassFromShapes();
         
         //Return Body
         return arbiBody;
      }
   }

}


The errors I'm getting are:
Quote:
ArbiStaticActor.as, Line 120 1046: Type was not found or was not a compile-time constant: b2ShapeDef.
ArbiStaticActor.as, Line 88 1046: Type was not found or was not a compile-time constant: b2PolygonDef.
ArbiStaticActor.as, Line 88 1180: Call to a possibly undefined method b2PolygonDef.
ArbiStaticActor.as, Line 123 1061: Call to a possibly undefined method CreateShape through a reference with static type Box2D.Dynamics:b2Body.
ArbiStaticActor.as, Line 127 1061: Call to a possibly undefined method SetMassFromShapes through a reference with static type Box2D.Dynamics:b2Body.


Could someone please help me update this class? I would rather not stick with an outdated Box2D to avoid these errors.
Once again I tried to fix it myself, and now I'm not getting the previous errors anymore.
This is how CreateBodyFromCoords now looks like!
Code:
   
      //Create Body From Coordinates
      private function CreateBodyFromCoords(arrayOfCoords:Array, location:Point):b2Body {
         //Body Defenition
         var bodyDef:b2BodyDef;
         bodyDef.position.Set(location.x / gameData.RATIO, location.y / gameData.RATIO);
         
         //Shape
         var shape:b2PolygonShape = new b2PolygonShape();
         for each (var pointList:Array in arrayOfCoords) {
            shape.SetAsArray(pointList, pointList.length()-1);
         }
               
         //Fixture definition
         var fixtureDef:b2FixtureDef = new b2FixtureDef();
         fixtureDef.density = 0.0;
         fixtureDef.friction = 0.0;
         fixtureDef.restitution = 0.0;
         fixtureDef.shape = shape;
         
         //Create the body
         var body:b2Body = gameData.world.CreateBody(bodyDef);
         body.CreateFixture(fixtureDef);
         gameData.world.CreateBody(bodyDef);
         
         //Return Body
         return body;
      }


The arrayOfCoords parameter value is in this case.
Code:
var bottomBoundaryCoords:Array = [[new Point(0, 0), new Point(640, 0), new Point(640, 10), new Point(0, 10)]];


So now I'm not getting any errors when Flash builds my project. But when the code gets executed I get this error:
Quote:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Actors::ArbiStaticActor/CreateBodyFromCoords()
at Actors::ArbiStaticActor()
at Game/SetupBoundaries()
at Game/InitBox2D()
at Game/InitMechanics()
at Game()


Does anyone know what I'm doing wrong here?
Well I finally fixed it myself.

It now works again, except for the CreateSpriteFromCoords function but only if I'm gonna use it again I'll fix it.

Now for those that got stuck in converting that class here's how CreateBodyFromCoords looks like now!
Code:
      //Create Body From Coordinates
      private function CreateBodyFromCoords(arrayOfCoords:Array, location:Point):b2Body {
         //Body Defenition
         var bodyDef:b2BodyDef = new b2BodyDef();
         bodyDef.position.Set(location.x / gameData.RATIO, location.y / gameData.RATIO);
         
         //Shape
         var shape:b2PolygonShape = new b2PolygonShape();
         shape.SetAsArray(arrayOfCoords, arrayOfCoords.length);
         
         //Fixture definition
         var fixtureDef:b2FixtureDef = new b2FixtureDef();
         fixtureDef.density = 0.0;
         fixtureDef.friction = 0.0;
         fixtureDef.restitution = 1.0;
         fixtureDef.shape = shape;
         
         //Create the body
         var body:b2Body = gameData.world.CreateBody(bodyDef);
         body.CreateFixture(fixtureDef);
         gameData.world.CreateBody(bodyDef);
         
         //Return Body
         return body;
      }


And this is the arrayOfCoords it gets passed on as a parameter.
Code:
var bottomBoundaryCoords:Array = [new b2Vec2(0 / gameData.RATIO, 0 / gameData.RATIO), new b2Vec2(640 / gameData.RATIO, 0 / gameData.RATIO), new b2Vec2(640 / gameData.RATIO, 10 / gameData.RATIO), new b2Vec2(0, 10)];


Improvements on the code are always welcome!

Original thread: https://box2d.org/forum/viewtopic.php?t=6771