| 包 | flash.text.engine |
| 类 | public final class GraphicElement |
| 继承 | GraphicElement ContentElement Object |
| 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5 |
content 属性,以使用 TextBlock.createTextLine() 显示图形或图像。将其分配给 GroupElement 对象以将其与其他图形和文本元素相结合。
另请参见
| 属性 | 定义方 | ||
|---|---|---|---|
![]() | constructor : Object
对类对象或给定对象实例的构造函数的引用。 | Object | |
![]() | elementFormat : ElementFormat 用于元素的 ElementFormat 对象。 | ContentElement | |
| elementHeight : Number 要为行中的图形保留的高度,以像素为单位。 | GraphicElement | ||
| elementWidth : Number 要为行中的图形保留的宽度,以像素为单位。 | GraphicElement | ||
![]() | eventMirror : EventDispatcher EventDispatcher 对象,该对象将接收调度到基于此内容元素的有效文本行的每个事件的副本。 | ContentElement | |
| graphic : DisplayObject 要用作 GraphicElement 的图形的 DisplayObject。 | GraphicElement | ||
![]() | groupElement : GroupElement [只读 (read-only)] 包含此元素的 GroupElement 对象;如果此元素不在一个组中,则为 null。 | ContentElement | |
![]() | prototype : Object [静态]
对类或函数对象的原型对象的引用。 | Object | |
![]() | rawText : String [只读 (read-only)] 元素中的文本的副本,包括 U+FDEF 字符。 | ContentElement | |
![]() | text : String [只读 (read-only)] 元素中的文本的副本,不包括表示 String 中的图形元素的 U+FDEF 字符。 | ContentElement | |
![]() | textBlock : TextBlock [只读 (read-only)] 此元素所属的 TextBlock。 | ContentElement | |
![]() | textBlockBeginIndex : int [只读 (read-only)] 文本块中此元素的第一个字符的索引。 | ContentElement | |
![]() | textRotation : String 应用于元素的旋转(旋转时将元素作为一个单元)。 | ContentElement | |
![]() | userData : * 为作者提供了一种将任意数据与元素相关联的途径。 | ContentElement | |
| 方法 | 定义方 | ||
|---|---|---|---|
GraphicElement(graphic:DisplayObject = null, elementWidth:Number = 15.0, elementHeight:Number = 15.0, elementFormat:ElementFormat = null, eventMirror:EventDispatcher = null, textRotation:String = "rotate0") 创建新的 GraphicElement 实例。 | GraphicElement | ||
![]() |
指示对象是否已经定义了指定的属性。 | Object | |
![]() |
指示 Object 类的实例是否在指定为参数的对象的原型链中。 | Object | |
![]() |
指示指定的属性是否存在、是否可枚举。 | Object | |
![]() |
设置循环操作动态属性的可用性。 | Object | |
![]() |
返回指定对象的字符串表示形式。 | Object | |
![]() |
返回指定对象的原始值。 | Object | |
| elementHeight | 属性 |
elementHeight:Number [读写] | 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5 |
要为行中的图形保留的高度,以像素为单位。调用方负责缩放图形。
默认值为 15.0。
public function get elementHeight():Number public function set elementHeight(value:Number):void| elementWidth | 属性 |
elementWidth:Number [读写] | 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5 |
要为行中的图形保留的宽度,以像素为单位。调用方负责缩放图形。
默认值为 15.0。
public function get elementWidth():Number public function set elementWidth(value:Number):void| graphic | 属性 |
graphic:DisplayObject [读写] | 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5 |
要用作 GraphicElement 的图形的 DisplayObject。
默认值为 null。
当 GraphicElement 成为文本行的一部分时,会将该图形添加为行的子项。如果设置图形,则将从行中删除旧图形并添加新图形。
public function get graphic():DisplayObject public function set graphic(value:DisplayObject):void| GraphicElement | () | 构造函数 |
public function GraphicElement(graphic:DisplayObject = null, elementWidth:Number = 15.0, elementHeight:Number = 15.0, elementFormat:ElementFormat = null, eventMirror:EventDispatcher = null, textRotation:String = "rotate0")| 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5 |
创建新的 GraphicElement 实例。
图形的注册点与 elementHeight、elementWidth 和 elementFormat.baselineShift 所定义的区域的左上角对齐。将不会为了与区域大小相匹配而缩放图形。如果 GraphicElement 具有 eventMirror、elementWidth 和 elementHeight 属性,但是没有图形,则可以确定生成的镜像区域的大小和位置。如果使用加载程序,则可能不会在创建文本行和镜像区域时加载图形。
graphic:DisplayObject (default = null) —
要填充 GraphicElement 的 DisplayObject。默认值为 null。
| |
elementWidth:Number (default = 15.0) — 为元素保留的区域的宽度,以像素为单位。默认值为 15。 | |
elementHeight:Number (default = 15.0) — 为元素保留的区域的高度,以像素为单位。默认值为 15。 | |
elementFormat:ElementFormat (default = null) —
元素的元素格式。默认值为 null。
| |
eventMirror:EventDispatcher (default = null) —
EventDispatcher 对象,该对象将接收调度到基于此内容元素创建的文本行的每个事件的副本。默认值为 null。
| |
textRotation:String (default = "rotate0") —
作为一个单元应用于元素的旋转。对此属性使用 flash.text.engine.TextRotation 常量。默认值为 flash.text.engine.TextRotation.ROTATE_0。
|
另请参见
package {
import flash.display.Sprite;
import flash.display.MovieClip;
import flash.text.engine.TextBlock;
import flash.text.engine.TextElement;
import flash.text.engine.GraphicElement;
import flash.text.engine.TextLine;
import flash.text.engine.ElementFormat;
import flash.text.engine.FontDescription;
public class GraphicElementExample extends Sprite {
public function GraphicElementExample():void {
var format:ElementFormat = new ElementFormat();
format.fontSize = 14;
var redBox:MovieClip = new MovieClip();
redBox.graphics.beginFill(0xCC0000, 1.0);
redBox.graphics.drawRect(0,0, 200, 200);
redBox.graphics.endFill();
var graphicElement:GraphicElement = new GraphicElement(redBox,redBox.width,redBox.height, format);
var textBlock:TextBlock = new TextBlock();
textBlock.content = graphicElement;
var textLine1:TextLine = textBlock.createTextLine(null,redBox.width);
addChild(textLine1);
textLine1.x = 15
textLine1.y = 215
var str:String = "Your picture here ...";
var textElement:TextElement = new TextElement(str, format);
textBlock = new TextBlock();
textBlock.content = textElement;
var textLine2 = textBlock.createTextLine(null, 300);
addChild(textLine2);
textLine2.x = textLine1.x;
textLine2.y += textLine1.y + format.fontSize;
}
}
}