[haXe] Bug in Flash MovieClip Drawing API?

Louis-Philippe Maurice maurice at ndimedia.com
Fri Nov 3 21:58:47 CET 2006


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 
> <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/20061103/bbcb5b0e/attachment.htm


More information about the Haxe mailing list