Rotation property bug?
A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Rotation property bug?

  1. #1
    Junior Member
    Join Date
    Feb 2008
    Posts
    6

    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};
    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, -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

  2. #2
    Flash developer
    Join Date
    Dec 2007
    Posts
    26
    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

  3. #3
    Flash developer
    Join Date
    Dec 2007
    Posts
    26
    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(10x000000100);

    colors = [0xFF00000x0000FF];
    fillType "linear"
    alphas = [100100];
    ratios = [0255];
    matrix = {matrixType:"box"x:0y:-10000w:10h:10000r:(90/180)*Math.PI};
    box.beginGradientFill(fillTypecolorsalphasratiosmatrix);

    //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(50);

    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......

  4. #4
    Junior Member
    Join Date
    Feb 2008
    Posts
    6
    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!

  5. #5
    Junior Member
    Join Date
    Jul 2015
    Posts
    2
    Any idea how to get around this problem when using tweens? I'm a character animator and this problem is driving me nuts.

    Here's an example. https://www.youtube.com/watch?v=aODQKrI1Ot0

    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.

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center

Poll by Flashkit.com