[haXe] Bug in Flash MovieClip Drawing API?

Keith Hall kingkeith at gmail.com
Sat Nov 4 13:04:01 CET 2006


Thanks Louis-Philippe for pointing out where I went wrong. Sorry I thought
it was a bug :(.

But I must admit that I am still a bit confused about why it mattered where
I ended the fill. I thought my method was the most logical way to draw a
square with a cross over it. I realise why moving the end fill to after the
cross has been drawn wouldn't fill in the cross - because it was 2
single lines seperated by a moveTo command, so there was no area to fill.

However, what I don't understand is why not filling the cross affected it so
badly. If someone could perhaps explain that to me, I would be most grateful
- and it would stop me making more similar mistakes in the future... ;)

Is there some law that states that everything has to have a fill even if
it's a transparent one? Or what am I missing here?

Thanks very much
Keith


On 04/11/06, haxe-request at lists.motion-twin.com <
haxe-request at lists.motion-twin.com> wrote:
>
> 4. Re: Bug in Flash MovieClip Drawing API? (Louis-Philippe Maurice)


---------- Forwarded message ----------
> From: Louis-Philippe Maurice <maurice at ndimedia.com>
> To: The haXe compiler list <haxe at lists.motion-twin.com>
> Date: Fri, 03 Nov 2006 15:58:47 -0500
> Subject: Re: [haXe] Bug in Flash MovieClip Drawing API?
> It's not a bug, you're calling endFill() at the wrong place. Here's the
> fix:
>
> // file Test.hx
> import flash.MovieClip;
> class Test {
>  static function main ():Void {
>   var mcTest:MovieClip = flash.Lib.current.createEmptyMovieClip('mcTest',
> flash.Lib.current.getNextHighestDepth());
>
>   var intSize:Int = 50;
>   mcTest.clear();
>
>   // draw background
>   mcTest.beginFill(0x00ccff);
>   Test.drawSquare(mcTest, 0, 0, intSize);
>
>
>   // draw a cross over the background
>   mcTest.lineStyle (2, 0xff0000, 100);
>   mcTest.moveTo(0, 0);
>   mcTest.lineTo(intSize, intSize);
>   mcTest.moveTo(intSize, 0);
>   mcTest.lineTo(0, intSize);
>   mcTest.endFill();
>   // draw a smaller square (in the middle of the background and cross)
>   //mcTest.lineStyle(0, 0xffffff, 0); // no line
>   mcTest.lineStyle(1.0, 0xffff00, 100);
>   mcTest.beginFill(0x00ff00);
>   intSize /= 2;
>   Test.drawSquare(mcTest, intSize / 2, intSize / 2, intSize);
>   mcTest.endFill ();
>  }
>
>  public static function drawSquare (mcDrawOn:MovieClip, fltX:Float,
> fltY:Float, fltSize:Float):Void {
>   Test.drawRect(mcDrawOn, fltX, fltY, fltSize, fltSize);
>  }
>
>  public static function drawRect (mcDrawOn:MovieClip, fltX:Float,
> fltY:Float, fltWidth:Float, fltHeight:Float):Void {
>   var fltEndX:Float = fltX + fltWidth;
>   var fltEndY:Float = fltY + fltHeight;
>
>   mcDrawOn.moveTo(fltX, fltY);
>   mcDrawOn.lineTo(fltEndX, fltY);
>   mcDrawOn.lineTo(fltEndX, fltEndY);
>   mcDrawOn.lineTo (fltX, fltEndY);
>   mcDrawOn.lineTo(fltX, fltY);
>  }
> }
>
>
> Louis-Philippe Maurice
>
>
> Keith Hall wrote:
>
> Hello list,
>
> I think I may have found a bug with the MovieClip drawing APIs. The way I
> replicated the bug was simply to draw a square over a "cross". The bug
> itself is a display issue, whereby
>  a) it isn't drawn correctly - bit's that should be filled in aren't, and
> lines that should be one color are a different color. Also, there is a black
> rectangle to the right of the MovieClip!?
>  b) it doesn't refresh the display correctly when you zoom in and move the
> viewport. Artefacts are left from some of the lines.
>
> I compiled it for Flash 7 and 8, testing with Flash Player 9. Also, I have
> only tried compiling it with haxe v1.08, so I can't tell you whether it's
> a new bug or not. (Sorry)
>
> I don't know that this mailing list accepts attachments like a screenshot,
> so I've made one available, along with the compiled movie and code
> files from http://www.kingkeith.co.uk/testbed/test.htm
>
> However, I shall also post the code here - I've made it as small as I
> reasonably could while maintaining readability (and the bug, of course):
>
> // file Test.hx
> import flash.MovieClip;
> class Test {
>  static function main ():Void {
>   var mcTest:MovieClip = flash.Lib.current.createEmptyMovieClip('mcTest',
> flash.Lib.current.getNextHighestDepth());
>
>   var intSize:Int = 50;
>   mcTest.clear();
>
>   // draw background
>   mcTest.beginFill(0x00ccff);
>   Test.drawSquare(mcTest, 0, 0, intSize);
>   mcTest.endFill();
>
>   // draw a cross over the background
>   mcTest.lineStyle (2, 0xff0000, 100);
>   mcTest.moveTo(0, 0);
>   mcTest.lineTo(intSize, intSize);
>   mcTest.moveTo(intSize, 0);
>   mcTest.lineTo(0, intSize);
>
>   // draw a smaller square (in the middle of the background and cross)
>   //mcTest.lineStyle(0, 0xffffff, 0); // no line
>   mcTest.lineStyle(1.0, 0xffff00, 100);
>   mcTest.beginFill(0x00ff00);
>   intSize /= 2;
>   Test.drawSquare(mcTest, intSize / 2, intSize / 2, intSize);
>   mcTest.endFill ();
>  }
>
>  public static function drawSquare (mcDrawOn:MovieClip, fltX:Float,
> fltY:Float, fltSize:Float):Void {
>   Test.drawRect(mcDrawOn, fltX, fltY, fltSize, fltSize);
>  }
>
>  public static function drawRect (mcDrawOn:MovieClip, fltX:Float,
> fltY:Float, fltWidth:Float, fltHeight:Float):Void {
>   var fltEndX:Float = fltX + fltWidth;
>   var fltEndY:Float = fltY + fltHeight;
>
>   mcDrawOn.moveTo(fltX, fltY);
>   mcDrawOn.lineTo(fltEndX, fltY);
>   mcDrawOn.lineTo(fltEndX, fltEndY);
>   mcDrawOn.lineTo (fltX, fltEndY);
>   mcDrawOn.lineTo(fltX, fltY);
>  }
> }
>
> // file Test.hxml
> -swf test.swf
> -main Test
> -debug
> -swf-version 7
> -swf-header 400:300:40:ffffff
> --flash-strict
> --override
>
>
> If this isn't a bug, but is something I am doing wrong please let me know,
> and I will apologise for thinking that HaXe is flawed. :)
> If it is a bug, perhaps someone could find more ways of replicating it, so
> from this information, the bug could be fixed easier... :D
>
> Thanks for your time
> Keith Hall
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.motion-twin.com/pipermail/haxe/attachments/20061104/7c540013/attachment.htm


More information about the Haxe mailing list