Package | flash.text.engine |
Class | public final class GraphicElement |
Inheritance | GraphicElement ContentElement Object |
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 10, AIR 1.5, Flash Lite 4 |
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.
More examples
Related API Elements
Property | Defined By | ||
---|---|---|---|
constructor : Object
A reference to the class object or constructor function for a given object instance. | Object | ||
elementFormat : ElementFormat
The ElementFormat object 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 valid 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 object that contains this element, or
null if it is not in a group. | ContentElement | ||
rawText : String [read-only]
A copy of the text in the element, including any U+FDEF characters. | ContentElement | ||
text : String [read-only]
A copy of the text in the element, not including any U+FDEF characters, which represent graphic elements in the String. | ContentElement | ||
textBlock : flash.text.engine: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 an application 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 this object, formatted according to locale-specific conventions. | Object | ||
Returns the string representation of the specified object. | Object | ||
Returns the primitive value of the specified object. | Object |
elementHeight | property |
elementHeight:Number
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 10, AIR 1.5, Flash Lite 4 |
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.
Implementation
public function get elementHeight():Number
public function set elementHeight(value:Number):void
elementWidth | property |
elementWidth:Number
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 10, AIR 1.5, Flash Lite 4 |
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.
Implementation
public function get elementWidth():Number
public function set elementWidth(value:Number):void
graphic | property |
graphic:DisplayObject
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 10, AIR 1.5, Flash Lite 4 |
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 removes the old graphic from the line and adds the new one.
Implementation
public function get graphic():DisplayObject
public function set graphic(value:DisplayObject):void
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 |
Runtime Versions: | Flash Player 10, AIR 1.5, Flash Lite 4 |
Creates a new GraphicElement instance.
The registration point of the graphic aligns with the upper-left corner
of the region defined by elementHeight
, elementWidth
and elementFormat.baselineShift
. The graphic is not scaled to match the size of the region.
If the GraphicElement has an eventMirror
, the elementWidth
and elementHeight
properties, and not the graphic, determine the size and position of the resulting mirror region. If a loader
is used, the graphic might not be loaded at the time the text line and the mirror regions are created.
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 to the element as a unit. Use flash.text.engine.TextRotation
constants for this property. The default value is flash.text.engine.TextRotation.ROTATE_0 .
|
Related API Elements
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; } } }
Thu Dec 6 2018, 01:12 PM -08:00