🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Object isn't drawing as vector graphics (Flash/Actionscript 3)

Started by
-1 comments, last by Cornstalks 15 years ago
I'm kinda new to this whole Flash/Actionscript 3 scene. I'm remaking one of my games in Flash so that people can play it on my website/blog (which doesn't exist :P). Anyway, I've got this shape I need to draw (the anaconda's head), and it's going to rotate so that it's always pointing towards the user's mouse. I created a Shape called head that I planned to simply rotate so that it would face user's mouse, but when I rotate it, Flash decides to rasterize it and cache it as a bitmap. If I don't rotate it, it draws as a vector image, but if I ever assign to the rotation member (even if it's just 0), it gets converted to a bitmap image. The code
package  
{
    import flash.display.Sprite;
    import flash.display.Shape;
    import flash.events.Event;
    
    public class Anaconda extends Sprite
    {
        private var head:Shape = new Shape();
                
        public function Anaconda() 
        {
            head.y = 30;
            //head.rotationZ = 0;
            head.graphics.lineStyle(1, 0xffffff);
            head.graphics.moveTo( 0,  -7);
            head.graphics.lineTo( 8, -10);
            head.graphics.lineTo(18,  -6);
            head.graphics.lineTo(20,  -4);
            head.graphics.lineTo(20,   4);
            head.graphics.lineTo(18,   6);
            head.graphics.lineTo( 8,  10);
            head.graphics.lineTo( 0,   7);
            head.cacheAsBitmap = false;
            
            // I've added this part just for a visual reference
            this.graphics.lineStyle(1, 0xffffff);
            this.graphics.moveTo( 0,  -7);
            this.graphics.lineTo( 8, -10);
            this.graphics.lineTo(18,  -6);
            this.graphics.lineTo(20,  -4);
            this.graphics.lineTo(20,   4);
            this.graphics.lineTo(18,   6);
            this.graphics.lineTo( 8,  10);
            this.graphics.lineTo( 0,   7);
            
            this.addChild(head);
            
            this.x = 100;
            this.y = 100;
        }
    }
}

And here are some images that show the problem. I've zoomed in to 400% so you can clearly see the difference. The head on the top is the one drawn with this.graphics (just for comparison) and the head on the bottom is the one drawn with head.graphics. With head.rotationZ = 0; commented out With head.rotationZ = 0; not commented out With some of my current plans, this is unnacceptable for me. I need it to be drawn with vector graphics. Now of course, I could just do the rotation transformation myself and plot the points, but I'd rather not. Is there a way to get the head to always draw as a vector image, even if I'm rotating? I've tried setting head.cacheAsBitmap = false; but that doesn't seem to have any affect; it still renders the head as a bitmap. Thanks in advance!
[size=2][ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]

This topic is closed to new replies.

Advertisement