GraphicsFilter: How do I get an image with a lot of diagonal jaggies in it to scroll without flickering? I think it's more of a general graphics problem than a Flash issue, but I've included the Flash details anyway.
I'm scrolling (by which I mean moving) a large bitmap using Flash CS 3. I'm doing this by putting the bitmap in a MovieClip and then changing the x property of the instance of the MovieClip in an OnEnterFrame listener.
It doesn't look outright horrible, but it definitely flickers in places.
Part of the issue may be the nature of the image. It's drawing-like, rather than photo-like. There are
jaggies, and the areas of the image with the highest concentrations of them flicker the most. (I notice that even the Bros. Chaps' excellent developer whose name I forgot couldn't quite avoid this happening in the foreground of the
Stinkoman game.) This is a requirement, however: The jaggies are intentional.
Some other details:
- Tracing the bitmap into a vector doesn't help.
- I move it 10 pixels per frame. When I change it to move 1 pixel per frame, it's smooth-looking. Unfortunately, I need it to move at a faster rate.
- It doesn't matter whether I set the frame rate to 12 or 60 fps. At 12, it flickers, and at 30 or over, it just looks blurry.
- Same thing with making the movement rate a multiple of four. (Each block in the jaggies is 4x4 pixels in size.)
- I had some other code (but not much) subscribed to the ENTER_FRAME event, but I dropped it so that the only code that executed on each frame entrance was myMovieClip.x += 10;. No help. So, it's not a processor load issue.
- I tried having it move in direct response to a keyboard event instead of the ENTER_FRAME event, but that didn't matter, either.
- Doing this via tweening doesn't seem to help.
Any clues? My Google attacks do not seem to be hooking anything relevant.
I do have a plan B, but I'd really like for this to work.
The way this typically works is that you have two buffers. You display your image in the first buffer. Then you draw your moved image in the second buffer, and tell the system to switch the two on vblank... that is, during the vertical refresh interval. Once the system indicates the two have switched, you now draw the image, moved even more, back into frame 1 again, and then tell the system to swap on vblank. Draw in 2 and swap, draw in 1 and swap. As long as you sync with the vertical refresh, you get no flicker.
How you do this in Flash, I have no idea, but I see smooth, flicker-free Flash animations all the time, so there's likely to be an easy method available.
posted by Malor at 3:09 AM on December 1, 2007