After successfully completing various tutorials I keep bumping onto a small problem that I can't seem to solve. I know I know, this probably is something small that I overlooked but I must have tunnelvision or something;)
I made a basic script to show what i mean. I made random sized blocks fall from random x positions onto a solid ground. Each time the timer releases a block ( a block = a movieclip called box) i see a rapid flash of the generated block in the top left corner and then it gets set to its random position. This flashing of blocks at the origin is very irritating and I want to get rid of it.
To make things more clear i have included the swf file. It would be great if someone could help me out.
I made a basic script to show what i mean. I made random sized blocks fall from random x positions onto a solid ground. Each time the timer releases a block ( a block = a movieclip called box) i see a rapid flash of the generated block in the top left corner and then it gets set to its random position. This flashing of blocks at the origin is very irritating and I want to get rid of it.
To make things more clear i have included the swf file. It would be great if someone could help me out.
Code:
public function on_time(e:Event) {
body1Def = new b2BodyDef();
box1Def = new b2PolygonDef();
var x = int;
var y = int;
body1Def.position.Set((Math.random()*30+2) / 2,0);//A little was added to make the boxes tilt left.
box1Def.SetAsBox(x = Math.random()+01 , y = Math.random()+0.1);
box1Def.density = 1.0;
box1Def.friction = 0.3;
body1Def.userData = new Box();
body1Def.userData.width = physScale * 2 * x ;
body1Def.userData.height = physScale * 2 * y ;
body1 = m_world.CreateBody(body1Def);
body1.CreateShape(box1Def);
body1.SetMassFromShapes();
addChild(body1Def.userData);
}
body1Def = new b2BodyDef();
box1Def = new b2PolygonDef();
var x = int;
var y = int;
body1Def.position.Set((Math.random()*30+2) / 2,0);//A little was added to make the boxes tilt left.
box1Def.SetAsBox(x = Math.random()+01 , y = Math.random()+0.1);
box1Def.density = 1.0;
box1Def.friction = 0.3;
body1Def.userData = new Box();
body1Def.userData.width = physScale * 2 * x ;
body1Def.userData.height = physScale * 2 * y ;
body1 = m_world.CreateBody(body1Def);
body1.CreateShape(box1Def);
body1.SetMassFromShapes();
addChild(body1Def.userData);
}