Symbol 3 MovieClip [textClip] Frame 1
#initclip 2
Object.registerClass("textClip", LocalizeableText);
#endinitclip
Symbol 4 MovieClip [__Packages.LocalizeableText] Frame 0
class LocalizeableText extends MovieClip
{
var _initialized, _textID, field;
function LocalizeableText () {
super();
if (_global._xmltext == undefined) {
initXML();
}
_global._xml_instances.push(this);
_initialized = true;
}
static function xmlLoaded() {
_global._xml_loaded = true;
var _local2;
var _local3;
_local2 = 0;
while (_local2 < _global._xml_instances.length) {
_local3 = _global._xml_instances.pop();
_local3.updateText();
_local2++;
}
}
static function initXML() {
if (_global._xmltext != undefined) {
return(undefined);
}
_global._xml_instances = new Array();
_global._xmltext = new XML();
_global._xmltext.ignoreWhite = true;
_global._xmltext.onLoad = xmlLoaded;
_global._xmltext.load("text.xml");
}
static function getByID(id) {
var _local2;
var _local3;
var _local4 = _global._xmltext.firstChild.childNodes;
_local2 = 0;
while (_local2 < _local4.length) {
_local3 = _local4[_local2];
if (_local3.attributes.id == id) {
return(_local3);
}
_local2++;
}
}
function updateText() {
if (_textID == undefined) {
return(undefined);
}
if (!_global._xml_loaded) {
trace("not _global._xml_loaded");
return(undefined);
}
setTextID(_textID);
}
function setText(txt) {
field.embedFonts = true;
var _local2 = field.getTextFormat();
field.text = txt;
field.setTextFormat(_local2);
}
function setTextID(id) {
_textID = id;
if (!_global._xml_loaded) {
return(undefined);
}
var _local5 = getByID(id);
if (_local5 == undefined) {
field.text = "";
return(undefined);
}
var _local6 = _local5.firstChild.firstChild.nodeValue;
field.embedFonts = _local5.attributes.useSystemFont != "true";
if (field.multiline) {
_local6 = _local6.split("\r\n").join(newline);
}
field.text = _local6;
var _local3 = _local5.lastChild;
if (_local3.nodeName == "textFormat") {
var _local4 = new TextFormat();
if (_local3.attributes.font != undefined) {
_local4.font = _local3.attributes.font;
}
if (_local3.attributes.size != undefined) {
_local4.size = Number(_local3.attributes.size);
}
if (_local3.attributes.color != undefined) {
_local4.color = Number(_local3.attributes.color);
}
if (_local3.attributes.align != undefined) {
_local4.align = _local3.attributes.align;
}
if (_local3.attributes.leading != undefined) {
_local4.leading = Number(_local3.attributes.leading);
}
field.setTextFormat(_local4);
}
}
}