A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Calculating area of a shape (no curves involved)

  1. #1
    </hate> dtone314's Avatar
    Join Date
    Jun 2005
    Location
    CA
    Posts
    262

    Question Calculating area of a shape (no curves involved)

    Hi all. I have some code that provides four draggable points with lines connecting them, as if you're dragging the corners of a room:
    Code:
    _root.createEmptyMovieClip("line_mc1", 1);
    
    MovieClip.prototype.drawLine = function()
    {
    	this.clear();
    	this.lineStyle(1,0x0000FF,100);
    	this.moveTo(mc1._x+mc1._width/2, mc1._y+mc1._height/2);
    	this.lineTo(mc2._x+mc2._width/2, mc2._y+mc2._height/2);
    	this.lineTo(mc3._x+mc3._width/2, mc3._y+mc3._height/2);
    	this.lineTo(mc4._x+mc4._width/2, mc4._y+mc4._height/2);
    	this.lineTo(mc1._x+mc1._width/2, mc1._y+mc1._height/2);
    	
    }
    
    mc1.swapDepths(2);
    mc2.swapDepths(3);
    mc3.swapDepths(4);
    mc4.swapDepths(5);
    
    line_mc1.drawLine();
    
    mc1.onPress = mc2.onPress = mc3.onPress = mc4.onPress = function()
    {
    	this.startDrag();
    	line_mc1.onEnterFrame = drawLine;
    }
    
    mc1.onRelease = mc2.onRelease = mc3.onRelease = mc4.onRelease = function()
    {
    	delete line_mc1.onEnterFrame;
    	this.stopDrag();
    }
    I am looking for a way to calculate the area of the shape that is made. I haven't had much success in finding how to calculate the area of irregular shapes, although I did find this which gives the general idea. It's just a little over my head: http://www.pharmacy.ferris.edu/facul...oordinates.pdf

    Any help pointing me in the right direction would be greatly appreciated, thanks!
    -dtøne-
    Flash CS4 | AS2
    Life is a journey, not a destination.

  2. #2
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    927
    see line 35 here
    who is this? a word of friendly advice: FFS stop using AS2

  3. #3
    </hate> dtone314's Avatar
    Join Date
    Jun 2005
    Location
    CA
    Posts
    262
    Hey, thanks, good stuff. This was a helpful link to an explanation of the formula used.
    -dtøne-
    Flash CS4 | AS2
    Life is a journey, not a destination.

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