Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/flash/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 flash/actionscript中的边界不正确_Actionscript 3_Flash_Bounds_Stroke - Fatal编程技术网

Actionscript 3 flash/actionscript中的边界不正确

Actionscript 3 flash/actionscript中的边界不正确,actionscript-3,flash,bounds,stroke,Actionscript 3,Flash,Bounds,Stroke,我有一个简单的UIComponent,它覆盖measure和updateDisplayList来绘制垂直线。通过考虑笔划宽度,我计算了线条的起点和终点。代码如下。我希望边界打印为x:0y:0w:1h:300,但它打印的是x:0y:0w:1h:299,即高度是299而不是300。我错过了什么 override protected function measure():void { super.measure(); measuredWidth = measuredMinWidth =

我有一个简单的UIComponent,它覆盖measure和updateDisplayList来绘制垂直线。通过考虑笔划宽度,我计算了线条的起点和终点。代码如下。我希望边界打印为x:0y:0w:1h:300,但它打印的是x:0y:0w:1h:299,即高度是299而不是300。我错过了什么

override protected function measure():void
{
    super.measure();
    measuredWidth = measuredMinWidth = 300;
    measuredHeight = measuredMinHeight = 300;
}

override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
{
    super.updateDisplayList(unscaledWidth, unscaledHeight);
    var stroke:SolidColorStroke = new SolidColorStroke(0xd8d8d8, 1, 1);

    var g:Graphics = graphics;
    g.clear();

    var bX:Number;
    var bY:Number;
    var tX:Number;
    var tY:Number;
    var bW:Number;
    var bH:Number;

    bX = stroke.weight * 0.5;
    bY = stroke.weight * 0.5;
    tX = stroke.weight * 0.5;
    tY = unscaledHeight - 1 - stroke.weight * 0.5;
    bW = unscaledWidth - stroke.weight;
    bH = unscaledHeight - stroke.weight;
    trace ("From (", bX, ",", bY, ") To (", tX, ",", tY, ")");

    stroke.apply(g, null, null);
    g.moveTo(bX, bY);
    g.lineTo(tX, tY);
    trace ("Bounds:", getBounds(this));
 }

你为什么用魔法数字→ -1.您已经拥有了所有的参数。tY的更改计算:


如果对象具有宽度,则高度为300300。那么它的x,y范围是0,0到299299,对吗?所以,如果我必须从y的最小值到y的最大值,它将是0到299,这是高度-1,对吗?如果笔划2,高度是300,它将是从y=1到y=299,如果我有一个黑色背景,我用moveTo0,0画了一条白线;第0行,第9行。像素0、9是黑色还是白色?换句话说,该线包括lineTo?moveTo0,0中给出的坐标;lineTo0,9-它将创建9像素长的白色线条感谢您的回答。这意味着像素0,9将不包括在内,对吗?至少这就是我使用-1的原因。因为最后一个像素将是无标度的,所以8-1。这是不对的吗?
tY = unscaledHeight - stroke.weight * 0.5;