我需要一些帮助来做我的一个小项目。
背景:我有一个Sprite派生类的小层次结构(从Flex Builder中的根应用程序类开始的5个级别)。宽度和高度属性被覆盖,以便我的类始终记住它所请求的大小(不仅仅是内容周围的边界大小),而且这些属性显式地将scaleX和scaleY设置为1,这样就不会涉及缩放。在存储这些值之后,调用draw()方法来重画内容。
绘图:绘图是非常直接的。只有最深的对象(在1-索引级别5)才会像这样向this.graphics对象中绘制内容:
var gr:Graphics = this.graphics;
gr.clear();
gr.lineStyle(0, this.borderColor, 1, true, LineScaleMode.NONE);
gr.beginFill(0x0000CC);
gr.drawRoundRectComplex(0, 0, this.width, this.height, 10, 10, 0, 0);
gr.endFill();更进一步:还有附加到绘制对象的父对象的MouseEvent.MOUSE_WHEEL事件。处理程序所做的仅仅是调整绘图对象的大小。
问题:Screenshot
当有时使用LineScaleMode.NONE设置来调整发际线边界线的厚度(通常甚至大于10px)+时,它通常会留下自己的痕迹(如蓝色框上方和下方的图片所示(请注意框本身有一个px黑色边框))。当我将lineStile thickness设置为NaN或alpha设置为0时,不会再出现这种情况。
一个多星期以来,我一直在回到这个问题上,放弃它去做一些其他的事情。
有没有人有主意?
备注:灰色背景是Flash Player本身的背景,不是我自己的选择。:D
根据要求,还有一点:应用程序应该是一个带有缩放“功能”(大学课程项目)的日历时间表。因此,我有一些与调整大小有关的函数:
public function performZoom():void
{
// Calculate new width:
var newDayWidth:Number = view.width / 7 * this.calModel.zoom;
if (newDayWidth < 1)
{
newDayWidth = 1;
}
var newWidth:int = int(newDayWidth * timeline.totalDays);
// Calculate day element Height/Width ratio:
var headerHeight:Number = this.timeline.headerAllDay;
var proportion:Number = 0;
if (this.view.width != 0 && this.view.height != 0)
{
proportion = 1 / (this.view.width / 7) * (this.view.height - this.timeline.headerAllDay);
}
// Calculate new height:
var newHeight:int = int(newDayWidth * proportion + this.timeline.headerAllDay);
// Calculate mouse position scale on X axis:
var xScale:Number = 0;
if (this.timeline.width != 0)
{
xScale = newWidth / this.timeline.width;
}
// Calculate mouse position scale on Y axis:
var yScale:Number = 0;
if (this.timeline.height - this.timeline.headerAllDay != 0)
{
yScale = (newHeight - this.timeline.headerAllDay) / (this.timeline.height - this.timeline.headerAllDay);
}
this.timeline.beginUpdate();
// Resize the timeline
this.timeline.resizeElement(newWidth, newHeight);
this.timeline.endUpdate();
// Move timeline:
this.centerElement(xScale, yScale);
// Reset timeline local mouse position:
this.centerMouse();
}
public function resizeElement(widthValue:Number, heightValue:Number):void
{
var prevWidth:Number = this.myWidth;
var prevHeight:Number = this.myHeight;
if (widthValue != prevWidth || heightValue != prevHeight)
{
super.width = widthValue;
super.height = heightValue;
this.scaleX = 1.0;
this.scaleY = 1.0;
this.myHeight = heightValue;
this.myWidth = widthValue;
if (!this.docking)
{
this.origHeight = heightValue;
this.origWidth = widthValue;
}
this.updateAnchorMargins();
onResizeInternal(prevWidth, prevHeight, widthValue, heightValue);
}
}是。我知道..很多核心和很多属性,但实际上大多数东西在最后都被禁用了,情况就像上面描述的那样。
这不起作用:
gr.lineStyle(); // Reset line style发布于 2010-05-22 18:25:58
我不知道是不是flash bug,或者是什么,但我最终找到了解决方案。
问题是,在我的例子中,当在nutshell中调整大小时,你会得到这样的结果:
this.width = this.stage.stageWidth / 7 * 365;当我切换到最大化窗口时,this.width获得了值86k+。当我添加这段代码来绘制水平线时,它自己修复了:
var recWidth:Number = this.width;
var i:int;
var newEnd:Number = 0;
for (i = 1; newEnd < recWidth; i++)
{
newEnd = 100 * i;
if (newEnd > recWidth)
{
newEnd = recWidth;
}
gr.lineTo(newEnd, 0);
}我不知道发生了什么..。这不方便..。
发布于 2010-05-22 04:28:05
我们能看看你调整大小的代码吗?
也可以尝试清除线条样式和填充内容:
gr.lineStyle(0, this.borderColor, 1, true, LineScaleMode.NONE);
gr.beginFill(0x0000CC);
gr.drawRoundRectComplex(0, 0, this.width, this.height, 10, 10, 0, 0);
gr.endFill();
gr.lineStyle();//<---- add this linehttps://stackoverflow.com/questions/2885298
复制相似问题