| Package | flash.text.engine |
| Class | public final class GraphicElement |
| Inheritance | GraphicElement ContentElement Object |
| Language Version : | ActionScript 3.0 |
| Player Version : | Flash Player 10 |
content property of a TextBlock object to display a graphic or an image with TextBlock.createTextLine(),
Assign it to a GroupElement object to combine it with other graphic and text elements.
See also
| Property | Defined By | ||
|---|---|---|---|
![]() | constructor : Object
A reference to the class object or constructor function for a given object instance. | Object | |
![]() | elementFormat : ElementFormat
The ElementFormat used for the element. | ContentElement | |
| elementHeight : Number
The height in pixels to reserve for the graphic in the line. | GraphicElement | ||
| elementWidth : Number
The width in pixels to reserve for the graphic in the line. | GraphicElement | ||
![]() | eventMirror : EventDispatcher
The EventDispatcher object that receives copies of every
event dispatched to text lines based on this content element. | ContentElement | |
| graphic : DisplayObject
The DisplayObject to be used as a graphic for the GraphicElement. | GraphicElement | ||
![]() | groupElement : GroupElement [read-only]
The GroupElement which contains this element, or
null if it is not in a group. | ContentElement | |
![]() | prototype : Object [static]
A reference to the prototype object of a class or function object. | Object | |
![]() | rawText : String [read-only]
A copy of the text in the element, including the U+FDEF characters representing graphic elements. | ContentElement | |
![]() | text : String [read-only]
A copy of the text in the element, not including the U+FDEF characters representing graphic elements. | ContentElement | |
![]() | textBlock : TextBlock [read-only]
The TextBlock to which this element belongs. | ContentElement | |
![]() | textBlockBeginIndex : int [read-only]
The index in the text block of the first character of this element. | ContentElement | |
![]() | textRotation : String
The rotation to apply to the element as a unit. | ContentElement | |
![]() | userData : *
Provides a way for the author to associate arbitrary data with the element. | ContentElement | |
| Method | Defined By | ||
|---|---|---|---|
GraphicElement(graphic:DisplayObject = null, elementWidth:Number = 15.0, elementHeight:Number = 15.0, elementFormat:ElementFormat = null, eventMirror:EventDispatcher = null, textRotation:String = "rotate0")
Creates a new GraphicElement instance. | GraphicElement | ||
![]() |
Indicates whether an object has a specified property defined. | Object | |
![]() |
Indicates whether an instance of the Object class is in the prototype chain of the object specified
as the parameter. | Object | |
![]() |
Indicates whether the specified property exists and is enumerable. | Object | |
![]() |
Sets the availability of a dynamic property for loop operations. | Object | |
![]() |
Returns the string representation of the specified object. | Object | |
![]() |
Returns the primitive value of the specified object. | Object | |
| elementHeight | property |
elementHeight:Number [read-write] | Language Version : | ActionScript 3.0 |
| Player Version : | Flash Player 10 |
The height in pixels to reserve for the graphic in the line. It is the responsibility of the caller to scale the graphic.
The default value is 15.0.
public function get elementHeight():Number public function set elementHeight(value:Number):voidArgumentError — the value is less than this.elementHeight.
|
| elementWidth | property |
elementWidth:Number [read-write] | Language Version : | ActionScript 3.0 |
| Player Version : | Flash Player 10 |
The width in pixels to reserve for the graphic in the line. It is the responsibility of the caller to scale the graphic.
The default value is 15.0.
public function get elementWidth():Number public function set elementWidth(value:Number):voidArgumentError — the value is less than this.elementWidth.
|
| graphic | property |
graphic:DisplayObject [read-write] | Language Version : | ActionScript 3.0 |
| Player Version : | Flash Player 9 |
The DisplayObject to be used as a graphic for the GraphicElement.
The default value is null.
When the GraphicElement becomes part of a text line, the graphic is added as a child of the line. Setting the graphic will remove the old graphic from the line and add the new one.
public function get graphic():DisplayObject public function set graphic(value:DisplayObject):voidArgumentError — the registration point of graphic is not at the top left.
| |
ArgumentError — the graphic.width is greater than this.elementWidth
or graphic.height is greater than this.elementHeight.
|
| GraphicElement | () | Constructor |
public function GraphicElement(graphic:DisplayObject = null, elementWidth:Number = 15.0, elementHeight:Number = 15.0, elementFormat:ElementFormat = null, eventMirror:EventDispatcher = null, textRotation:String = "rotate0")| Language Version : | ActionScript 3.0 |
| Player Version : | Flash Player 10 |
Creates a new GraphicElement instance.
The registration point of the graphic aligns with the top left corner
of the region defined by elementHeight, elementWidth
and elementFormat.baselineShift. The registration point of the graphic
must be at the top left corner of the graphic. The graphic will not be scaled to match the size of the region.
graphic:DisplayObject (default = null) — The DisplayObject to populate the GraphicElement. The default value is null.
| |
elementWidth:Number (default = 15.0) — The width of the area reserved for the element in pixels. The default value is 15.
| |
elementHeight:Number (default = 15.0) — The height of the area reserved for the element in pixels. The default value is 15.
| |
elementFormat:ElementFormat (default = null) — The element format for the element. The default value is null.
| |
eventMirror:EventDispatcher (default = null) — The EventDispatcher object that receives copies of every
event dispatched to text lines created based on this content element. The default value is null.
| |
textRotation:String (default = "rotate0") — The rotation applied the element as a unit. Use flash.text.engine.TextRotation
constants for this property. The default value is flash.text.engine.TextRotation.ROTATE_0.
|
ArgumentError — the registration point of graphic is not at the top left (0, 0).
| |
ArgumentError — the graphic.width is greater than elementWidth
or graphic.height is greater than elementHeight.
|
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;
}
}
}