dcsimg
A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Can anyone explain this _rotation limit?

  1. #1
    Senior Member
    Join Date
    Jul 2002
    Posts
    153

    Can anyone explain this _rotation limit?

    Havent seen anything on this possible bug.. Has anyone else?

    (Windows XP & Flash MX 2004 Pro)

    Set up an MC, use a button on(click) to set the _rotation to 32768. 32768 is actually 8 degrees (360 goes into 32760 exactly 91 times) but it sets the rotation to around 350 or so.

    Setting _rotation to 32767 or lower is fine, as well as incrementing _rotation to over 32767. Just when you directly set rotation to 32768 or over.

    Thought this was interesting.. But nothing anyone cant work around.

    -John

  2. #2
    Living Proof mave_the_rave's Avatar
    Join Date
    May 2002
    Location
    East Dulwich
    Posts
    1,006
    I believe there is a problem if you set rotation to >180 degrees
    I think it goes backwards ??

    If you say your rotation = 8 degrees then 360-8 is 352 which is very
    near your 350ish degrees...
    If someone tells you it can't be done,
    it's probally because they don't know how.

  3. #3
    Senior Member
    Join Date
    Jul 2002
    Posts
    153
    While it makes sense for the movie to break because of that answer, flash is 'supposed' to be smart enough to convert any number to a degree from 0-360. Over 360 and it is smart enough to figure out what the user wants..

    Not a problem, when I need to incorporate a rotation that may ascend or descend above 360 or below -360 I throw in a condition that resets my degrees once over 360 as this makes it easier for me. Still though, up over 32767 or as i've tested down below -32768 flash loses about 10 degrees. Any number in between though flash plots correctly.

    Just thought it was an interesting 'bug' nonetheless.. : )

  4. #4
    Senior Member
    Join Date
    May 2001
    Posts
    1,838
    32768 is 2^15; So, I guess Flash manipulate the _rotation by a memory of 16 bits storage. Maybe it is something like overflow error.

  5. #5
    omglolkthxbye
    Join Date
    Feb 2005
    Posts
    64
    ah yes, the magic number, 32767, the highest value a signed 2byte integer can hold. if you increment that value the sign-bit is flipped and the value is interpreted as negative, thus 32767 + 1 = -32767

    this would again mean a rotation of -32767 deg. and explains a rotation of -8 deg, or "about" 350 deg as you have experienced

    the only thing that bugs me though, is that i think that flash uses a float value for the actual _rotation variable, but i guess thats just how the as-interpreter works, to deep into programming for me.

    what you could try is casting that value into a float first, like
    inst._rotation = 32768.0;
    (does this work in flash anyway?)

    greez
    ubersquid

  6. #6
    Senior Member
    Join Date
    Aug 2002
    Location
    Dublin, Ireland
    Posts
    1,749
    The observation is correct, but you can get around it using the % operator.
    EG:
    code:

    stop();
    function pointer(c:Number) {
    var z:Number = this.getNextHighestDepth();
    var bob:MovieClip = this.createEmptyMovieClip("mc"+z, z);
    bob.beginFill(c, 50);
    bob.moveTo(0, 0);
    bob.lineTo(-10, 10);
    bob.lineTo(100, 0);
    bob.lineTo(-10, -10);
    bob.lineTo(0, 0);
    bob.endFill();
    return bob;
    }
    var raw_rotation:Number = 32500;
    var reallySmallNumber:MovieClip = pointer(0xff00);
    var bigNumber:MovieClip = pointer(0xff0000);
    var smallNumber:MovieClip = pointer(255);
    this.onEnterFrame = function() {
    raw_rotation++;
    var rsn:Number = raw_rotation-32760-32760-360;
    var bn:Number = raw_rotation
    var sn:Number = raw_rotation%360
    reallySmallNumber._rotation = rsn;
    bigNumber._rotation = bn;
    smallNumber._rotation = sn;
    var s = "Raw value: "+raw_rotation+"\n";
    s += "\trsmall\tbig\tsmall\n";
    s += "\t"+rsn+"\t"+bn+"\t"+sn+"\n";
    s += "\t"+reallySmallNumber._rotation+"\t"+bigNumber._r otation+"\t"+smallNumber._rotation+"\n";
    trace(s);
    };


    (ps: Using .0 or .1 has no effect.)

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