Если сможешь разобраться, то мой класс как раз делает текст с иконками внутри.
В данном случае создаётся старлинговый текст филд, класс Resources отвечает за работа с ассетами, поэтому из него берётся шрифт и картинки.
Ещё этот класс умеет части текста в разные цвета.
Код:
<red>Красный текст с иконкой [red_icon]</red> и <blue>синий текст с иконкой [blue_icon]</blue>

Код:
package ru.isaenkov.text
{
import flash.geom.Rectangle;
import flash.text.AntiAliasType;
import flash.text.TextField;
import flash.text.TextFormat;
import starling.display.Image;
import starling.display.Sprite;
import starling.text.TextField;
import starling.text.TextFieldAutoSize;
import starling.utils.HAlign;
public class IconTextField extends Sprite
{
public static const BLACK : uint = 0x000000;
public static const WHITE : uint = 0xFFFFFF;
public static const RED : uint = 0xff0000;
public static const BLUE : uint = 0x407DC1;
public static const GREEN : uint = 0x00FF00;
public static const YELLOW : uint = 0xFFFF00;
private var helper : flash.text.TextField = new flash.text.TextField();
private var spaceRect : Rectangle;
private var textField : starling.text.TextField;
private var images : Vector.<Image>;
public function IconTextField(type : uint, x : int, y : int, color : uint, text : String, size : uint, width : Number,
height : int = 0, align : String = HAlign.LEFT)
{
this.x = x;
this.y = y;
textField = createTextField(0, 0, color, text, size, width, height, align);
addChild(textField);
var textFormat : TextFormat = new TextFormat(Resources.FONT_FUTURA, size, color, false, false, false, null, null,
align);
textFormat.kerning = true;
textFormat.leading = 0.0;
helper.defaultTextFormat = textFormat;
helper.width = width;
helper.antiAliasType = AntiAliasType.ADVANCED;
helper.selectable = false;
helper.multiline = true;
helper.wordWrap = true;
helper.embedFonts = true;
helper.text = " ";
helper.height = helper.textHeight;
spaceRect = helper.getCharBoundaries(0);
setText(text);
}
private function createTextField(x : int, y : int, color : uint, text : String, size : uint, width : Number, height : int =
0, align : String = HAlign.LEFT) : starling.text.TextField
{
var field : starling.text.TextField = new starling.text.TextField(width, 0, text, Resources.FONT_FUTURA);
field.x = x;
field.y = y;
field.color = color;
field.fontSize = size;
field.hAlign = align;
if (height > 0)
{
field.autoSize = TextFieldAutoSize.NONE;
field.height = height;
}
else
{
field.autoSize = width <= 0 ? TextFieldAutoSize.BOTH_DIRECTIONS : TextFieldAutoSize.VERTICAL;
}
field.touchable = false;
return field;
}
public function setWidth(width : Number) : void
{
textField.width = width;
helper.width = width;
}
public function setText(text : String) : void
{
if (text == null || text.length == 0)
{
textField.text = "";
return;
}
var regExp : RegExp = /\[(.*?)\]/g
var array : Array = text.match(regExp);
var colorText : String = text;
for each (var key : String in array)
{
colorText = colorText.replace(key, "");
}
regExp = /<(.*?)>/g
var colors : Array = colorText.match(regExp);
var colorIndices : Vector.<uint> = new Vector.<uint>();
for each (var color : String in colors)
{
var index : int = colorText.indexOf(color);
colorIndices.push(index);
colorText = colorText.replace(color, "");
text = text.replace(color, "");
}
if (images != null)
{
for each (var image : Image in images)
{
removeChild(image);
image.dispose();
}
}
images = new Vector.<Image>();
var indices : Vector.<uint> = new Vector.<uint>();
var counters : Vector.<Number> = new Vector.<Number>();
for each (key in array)
{
var name : String = "ui/icons/" + key.replace("[", "").replace("]", "");
if (!Resources.hasImage(Resources.ATLAS, name))
{
continue;
}
image = Resources.getImage(Resources.ATLAS, name);
image.scaleX = image.scaleY = spaceRect.height / image.height;
images.push(image);
var spaceCounter : uint = Math.ceil(image.width / spaceRect.width);
var extraSpace : Number = spaceCounter - image.width / spaceRect.width;
var space : String = "";
for (var j : uint = 0; j < spaceCounter; j++)
{
space += " ";
}
index = text.indexOf(key);
text = text.replace(key, space);
indices.push(index);
counters.push(spaceCounter + extraSpace);
for (var i : uint = 0; i < colorIndices.length; i++)
{
if (colorIndices[i] > index)
{
colorIndices[i] += space.length;
}
}
}
helper.text = text;
helper.height = helper.textHeight * helper.numLines;
//handle rearranged string
for (i = 0; i < images.length; i++)
{
var rect : Rectangle = helper.getCharBoundaries(indices[i]);
images[i].x = Math.round(helper.x + rect.x + (rect.width * counters[i] - images[i].width) / 2);
images[i].y = Math.round(helper.y + rect.y + (rect.height - images[i].height) / 2);
addChild(images[i]);
setChildIndex(images[i], 0);
}
textField.text = helper.text;
if (colorIndices.length == 0)
{
return;
}
colorText = "";
for (i = 0; i < colorIndices.length; i++)
{
if (i == 0)
{
colorText += textField.text.substring(0, colorIndices[i]);
}
if ((colors[i] as String).indexOf("/") < 0)
{
colorText += "<font color='#" + getColor(colors[i]).toString(16) + "'>";
}
else
{
colorText += "</font>";
}
colorText += textField.text.substring(colorIndices[i], (i + 1) >= colorIndices.length ? textField.text.length :
colorIndices[i + 1]);
}
textField.isHtmlText = true;
textField.text = colorText;
}
private function getColor(str : String) : uint
{
switch (str)
{
case "<red>":
return RED;
case "<blue>":
return BLUE;
case "<green>":
return GREEN;
case "<yellow>":
return YELLOW;
}
return WHITE;
}
public function getTextBounds() : Rectangle
{
return textField.textBounds;
}
public function destroy() : void
{
spaceRect = null;
textField = null;
images = null;
helper = null;
}
}
}