A Flash Developer Resource Site

1. ## Rotation property bug?

Below you will find some code that vividly illustrates my point. The problem is that the rotation of massive objects will result in jerky behavior on their outer extremes. It can even randomly go into a shake when moving occurs at its extremes. This only happens on large objects at their outer edge when their rotation is less than 1. I did this at 30/60/120 fps and I can see the same results.

I really need to find a way around this problem. You can test the code in mx or 8, not cs3. Any help would be appreciated. Thanks!

Code:
```createEmptyMovieClip("box", 1);
box._x = 275;
box._y = 2500;
box.lineStyle(1, 0x000000, 100);

colors = [0xFF0000, 0x0000FF];
fillType = "linear"
alphas = [100, 100];
ratios = [0, 255];
matrix = {matrixType:"box", x:0, y:-10000, w:10, h:10000, r:(90/180)*Math.PI};

//  {matrixType:"box", x:0, y:0, w:10, h:10000, r:100});
box.moveTo(-5,0);
box.lineTo(-5, -10000);
box.lineTo(5, -10000);
box.lineTo(5, 0);

_root.onEnterFrame = function(){
if(Key.isDown(Key.LEFT)){
box._rotation -= 0.05;
}
if(Key.isDown(Key.RIGHT)){
box._rotation += 0.05;
}
if(Key.isDown(Key.UP)){
box._y -= 50;
}
if(Key.isDown(Key.DOWN)){
box._y += 50;
}
}
box.endFill```  Reply With Quote

2. Hi,

I think your problem comes from the fact that _rotation property can't take on a smooth range of values so adding 0.05 each time will not change the screen appearance every frame leading to a jerky behaviour. If exact rotation tracking is important for (ie in games) then it's best to keep your rotation variable (say Rot) separate and then update the _rotation property each frame:

_rotation = Rot

Hope this helps  Reply With Quote

3. Seems you can get around it by using the matrix class:
PHP Code:
``` import flash.geom.Matrix; import flash.geom.Transform; var myMatrix:Matrix = new Matrix(); myMatrix.rotate(2); //myMatrix.translate(200,200) createEmptyMovieClip("box", 1); box._x = 275; box._y = 400; box.lineStyle(1, 0x000000, 100); colors = [0xFF0000, 0x0000FF]; fillType = "linear" alphas = [100, 100]; ratios = [0, 255]; matrix = {matrixType:"box", x:0, y:-10000, w:10, h:10000, r:(90/180)*Math.PI}; box.beginGradientFill(fillType, colors, alphas, ratios, matrix); //box.beginGradientFill("radial", [0x000000, 0x0000ff], [100, 100], [0, 255],   //  {matrixType:"box", x:0, y:0, w:10, h:10000, r:100}); box.moveTo(-5,0); box.lineTo(-5, -400); box.lineTo(5, -400); box.lineTo(5, 0); var boxTrans:Transform = new Transform(box); boxTrans.matrix = myMatrix; _root.onEnterFrame = function(){     if(Key.isDown(Key.LEFT)){         myMatrix.rotate(0.001)         var boxTrans:Transform = new Transform(box);         boxTrans.matrix = myMatrix;     }     if(Key.isDown(Key.RIGHT)){         myMatrix.rotate(-0.001)         var boxTrans:Transform = new Transform(box);         boxTrans.matrix = myMatrix;     }     if(Key.isDown(Key.UP)){         box._y -= 50;     }     if(Key.isDown(Key.DOWN)){         box._y += 50;     } } box.endFill  ```
Hope this helps, maybe someone knows a better way......  Reply With Quote

4. Matrix Rotation! That did it! I was going to look into the geom package but I thought it would act the same. Seriously, well done and thanks for the help! Issue Solved!  Reply With Quote

5. Any idea how to get around this problem when using tweens? I'm a character animator and this problem is driving me nuts.

I've tried everything I can think of, checked pivot points, turned options on and off, classic and motion tweens, fps, checked the scale of the symbols... nothing works. Tried CS4, 6 and CC.  Reply With Quote

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

 » Home » Movies » Tutorials » Submissions » Board » Links » Reviews » Feedback » Gallery » Fonts » The Lounge » Sound Loops » Sound FX » About FK » Sitemap 