Creating a custom geometry with a color material works fine. But if I create it with a TextureMaterial it gives me this error.
TypeError: Error #2007: Parameter data must be non-null.
Here is the code I am using to create a custom geometry add it to a mesh and then to stage.
var geo:Geometry = new Geometry();
var ioff:uint = 0;
var point:Vector3D = new Vector3D(0,0,0);
var half:uint = 10;
var vertices:Vector.<Number> = new Vector.<Number>();
vertices[ioff + 0] = point.x + half; vertices[ioff + 1] = point.y + half; vertices[ioff + 2] = point.z + half;
vertices[ioff + 3] = point.x + -half; vertices[ioff + 4] = point.y + half; vertices[ioff + 5] = point.z + half;
vertices[ioff + 6] = point.x + -half; vertices[ioff + 7] = point.y + -half; vertices[ioff + 8] = point.z + half;
vertices[ioff + 9] = point.x + half; vertices[ioff + 10] = point.y + -half; vertices[ioff + 11] = point.z + half;
var uvs:Vector.<Number> = Vector.<Number>([0, 0, 1, 0, 1, 1, 0, 1]);
// indexes
var indexes:Vector.<uint> = Vector.<uint>([0,1,2,0,2,3]);
var sg:SubGeometry = new SubGeometry();
sg.updateIndexData(indexes);
sg.updateVertexData(vertices);
sg.updateVertexNormalData(uvs);
geo.addSubGeometry(sg);
// var mat:ColorMaterial = new ColorMaterial(0xFF6600);
var mi:MaterialIndex = new MaterialIndex();
var mat:MaterialBase = new TextureMaterial(new BitmapTexture(mi.bitmaps[0]));
mat.lightPicker = lightPicker;
// mat.bothSides = true;
mesh = new Mesh(geo, mat);
// mesh.castsShadows = true;
scene.addChild(mesh)