什么是扩展flash.display.Sprite和利用水平低的DisplayObject层次的ActionScript 3的可视化,以创建多个滚动区域的最佳方式(Sprite'a,形状的,文本字段) ?滚动区域
我试图使用三个mx.containers.Canvas对象作为主Sprite的子对象添加,并尝试将主Sprite转换为Canvas,但无法使用任一方法显示任何内容。我也尝试使用Canvas.addChild和Canvas.rawChildren.addChild添加我的DisplayObject。
是否有必要/可能重写使用MX整个事情。*成分还是有一招,一个Canvas对象内部的显示更为原始的对象?
下面是该作品使用精灵的方式一些示例代码。我们希望使用链接的滚动条制作_colSprite,_rowSprite和_mapSprite卷轴。当我将它们转换为Canvas对象时,代码在任何显示对象绘制之前静默地挂起(在addChild行,如果我正确记得)。
下面是代码的摘录。这全部来自扩展精灵的单个动作类。
塞汀三个区域我想滚动:
this._log("Creating Sprites");
this._colSprite = new Sprite();
this._colSprite.y=0;
this._colSprite.x=this._rowLabelWidth + this._rowLabelRightPadding + this._horizontalPadding;
this._rowSprite = new Sprite();
this._rowSprite.y=this._columnLabelHeight+this._columnLabelBottomPadding + this._verticalPadding;
this._rowSprite.x=this._horizontalPadding;
this._mapSprite = new Sprite();
this._mapSprite.y=this._columnLabelHeight+this._columnLabelBottomPadding+ this._verticalPadding;
this._mapSprite.x=this._rowLabelWidth + this._rowLabelRightPadding+this._horizontalPadding;
this._log("adding kids");
addChild(this._mapSprite);
addChild(this._rowSprite);
addChild(this._colSprite);
样品绘图功能:
private function _drawColumLabels(colStartIndex: int): void {
for (var col : int = colStartIndex; col < myData.g.length; col++) {
var colName : String = this.myData.g[col].label;
var bottomLeftPoint : Object = this._getCellXYTopLeft(0, col);
bottomLeftPoint.y = this._columnLabelHeight + this._verticalPadding;
var centerX : int = Math.round(this._cellWidth/2 + (this._fontHeight/2) - 1);
var colLabel : TextField = new TextField();
colLabel.defaultTextFormat = this._labelTextFormat;
colLabel.width = this._columnLabelHeight+this._columnLabelBottomPadding;
colLabel.text = colName;
colLabel.embedFonts = true;
var colSprite : Sprite = new Sprite();
colSprite.addChild(colLabel);
colSprite.x = bottomLeftPoint.x;
colSprite.y = bottomLeftPoint.y;
colSprite.rotation = -45;
this._colSprite.addChild(colSprite);
}
}
画布应自动显示滚动条,除非verticalScrollPolicy为“off”。你有一些你可以发布的代码来给出更多关于发生的事情的想法吗? – 2008-10-02 18:25:23