我在我的程序中使用 graphics.lineTo(xx,yy);如何给图形创建的对象提供深度?
该程序有一个背景图像,通过这些图像绘制这些线条。 我面临的问题是图像遮蔽了线条,线条对用户不可见。
由于这些行没有ID,我不知道如何为它们分配深度?
任何输入/建议都会有帮助吗?
我在我的程序中使用 graphics.lineTo(xx,yy);如何给图形创建的对象提供深度?
该程序有一个背景图像,通过这些图像绘制这些线条。 我面临的问题是图像遮蔽了线条,线条对用户不可见。
由于这些行没有ID,我不知道如何为它们分配深度?
任何输入/建议都会有帮助吗?
我不知道你的代码,但我会尽量指出一个方向。造成这种情况的最好办法是将组件与特定orger类似下面的应用程序:
<s:Group>
<s:BitmapImage />
<MyCustomComponent />
</s:Group>
哪里MyCustomComponent
是类似以下内容:
public class MyCustomComponent extends UIComponent
{
override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
{
super.updateDisplayList(unscaledWidth, unscaledHeight);
// Your drawings here: graphics.lineTo(xx, yy);
}
}
所以,现在您的图纸将在更高级别比图像。
的Z-index设置在显示列表 如果你想带什么东西到显示列表的顶部正好再次的addChild 例如
// this will place the BG on top of the myLinesSprite object
var container:Sprite = new Sprite();
container.addChild(myLinesSprite);
container.addChild(myBGimage);
// now do another addchild
var container:Sprite = new Sprite();
container.addChild(myLinesSprite);
container.addChild(myBGimage);
container.addChild(myLinesSprite); // updates displayList does not add twice
// of course if you build it correctly the first time you wont have a worry
var container:Sprite = new Sprite();
container.addChild(myBGimage);
container.addChild(myLinesSprite);