A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: localToGlobal with fractional pixels?

  1. #1
    Junior Member
    Join Date
    Feb 2007
    Posts
    22

    localToGlobal with fractional pixels?

    I'm working on a project where I need to use localToGlobal with a bit more precision than whole pixels because I have an object that is moving very slowly that I need something else to follow. Since localToGlobal returns whole pixels, the object I'm positioning with it jumps from pixel to pixel at slow speeds, rather than moving smoothly at fractional pixels like the object it's following.

    It does not seem that fractional pixels are possible with localToGlobal. Does anyone know of a custom class out there that I might be able to use, or some insight as to how I could create one to handle this?

  2. #2
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    Put some traces on your localToGlobal point - it should be type Number, so it should have the accuracy you need. It's more likely that your follow object is either getting cached to bitmap, doesn't have smoothing on, or has pixelSnapping set to true.
    Please use [php] or [code] tags, and mark your threads resolved 8)

  3. #3
    Junior Member
    Join Date
    Feb 2007
    Posts
    22
    Thank you for your insight and quick reply. I put some traces in there and got the following:

    localY:-234.35
    globalY:356
    localY:-254.1
    globalY:348
    localY:-273.25
    globalY:340
    localY:-291.8

    So it is reading the nested clip's coordinates, but the fractions are lost in the translation. Here's some more info.

    The clip containing the object I'm following has been transformed using root.transform.perspectiveProjection with it's .rotationX = -90. Essentially, I have two courts (think shuffleboard), one with an above view, and one in 3d.

    The issue I'm having is that I need the object in the 3d rendering to stand up rather than being flattened to the floor. Transforming its .rotationX = 90 to stand it up does not work. Regardless, I'm not happy with the quality when my vector image is converted to bitmap because of the 3d. So I'd rather follow a hidden object on the 3d plane with a vector image outside of the 3d transformed clip for a higher quality rendering.

    My follower object is definitely vector, not bitmap. Maybe the fact that the object it's following is a bitmap has to do with it, even though I'm getting fractional pixels if I trace the coordinates? If so, can I do a localToGlobal on a point instead of the clip?

    This is what I'm doing now:

    var myPoint:Point = new Point(0, 0);
    myPoint = objectToFollow.localToGlobal(myPoint);
    follower.x = myPoint.x;
    follower.y = myPoint.y;

  4. #4
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    The values getting traced are rational so the problem is in the follower position - try just moving the follower on an enterFrame by .125 pixels and see if it's smooth there.
    Please use [php] or [code] tags, and mark your threads resolved 8)

  5. #5
    I'm not sure I understand. The issue arises when the object slows down like below. It is moving fractionally within the clip, but I'm getting whole numbers back instead of fractions so it's jumpy. Is it possible for localToGlobal to return fractions?

    localY:-2064.85
    globalY:69
    localY:-2065.6
    globalY:69
    localY:-2066.35
    globalY:69
    localY:-2067.1
    globalY:69
    localY:-2067.8
    globalY:69
    localY:-2068.5
    globalY:68
    localY:-2069.2
    globalY:68
    localY:-2069.85
    globalY:68
    localY:-2070.5
    globalY:68
    localY:-2071.15
    globalY:68

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