Instance of Symbol 4 MovieClip [NPTranslator] in Frame 1
//component parameters
onClipEvent (construct) {
debug = false;
lang = {};
lang.targetName = "_level0";
lang.variableName = "lang";
lang.defaultValue = "en";
typeID = {};
typeID.targetName = "_level0";
typeID.variableName = "typeID";
typeID.defaultValue = 14;
itemID = {};
itemID.targetName = "_level0";
itemID.variableName = "itemID";
itemID.defaultValue = 101;
playMode = "AUTOMATIC";
}
Frame 2
if (_level0.flashXML == undefined) {
_level0.flashXML = "<message success = '1' text = ''>";
_level0.flashXML = _level0.flashXML + "<books>";
_level0.flashXML = _level0.flashXML + "<book>";
_level0.flashXML = _level0.flashXML + "<pages>";
_level0.flashXML = _level0.flashXML + "<page>";
_level0.flashXML = _level0.flashXML + "<number>7</number>";
_level0.flashXML = _level0.flashXML + "<title>The middle Title</title>";
_level0.flashXML = _level0.flashXML + (("<url>http://images50.neopets.com/medieval/comic_book/pages/book0/book0_page7_v1.swf?devRandom=" + random(10000)) + "</url>");
_level0.flashXML = _level0.flashXML + "</page>";
_level0.flashXML = _level0.flashXML + "<page>";
_level0.flashXML = _level0.flashXML + "<number>8</number>";
_level0.flashXML = _level0.flashXML + "<title>The middle Title</title>";
_level0.flashXML = _level0.flashXML + (("<url>http://images50.neopets.com/medieval/comic_book/pages/book0/book0_page8_v1.swf?devRandom=" + random(10000)) + "</url>");
_level0.flashXML = _level0.flashXML + "</page>";
_level0.flashXML = _level0.flashXML + "</pages>";
_level0.flashXML = _level0.flashXML + "</book>";
_level0.flashXML = _level0.flashXML + "</books>";
_level0.flashXML = _level0.flashXML + "</message>";
}
myComicBookShell = new ComicBookShell();
myComicBookShell.setNextMC(_root.next_mc);
myComicBookShell.setPreviousMC(_root.previous_mc);
myComicBookShell.setNextButton(_root.next_mc.next_btn);
myComicBookShell.setPreviousButton(_root.previous_mc.previous_btn);
myComicBookShell.setTitleText(_root.title_txt);
myComicBookShell.setXML(_level0.flashXML);
myComicBookShell.init();
stop();
Symbol 4 MovieClip [NPTranslator] Frame 1
#initclip 4
_global.EventBroadcaster = new Object();
EventBroadcaster.initialize = function (obj) {
obj._listeners = new Array();
obj.broadcastMessage = this._broadcastMessage;
obj.addListener = this._addListener;
obj.removeListener = this._removeListener;
};
EventBroadcaster._broadcastMessage = function () {
var eventName = arguments.shift();
var list = this._listeners;
for (var i in list) {
list[i][eventName].apply(list[i], arguments);
}
};
EventBroadcaster._addListener = function (obj) {
this.removeListener(obj);
this._listeners.push(obj);
return(true);
};
EventBroadcaster._removeListener = function (obj) {
var list = this._listeners;
var i = list.length;
for (var i in list) {
if (list[i] == obj) {
list.splice(i, 1);
return(true);
}
}
return(false);
};
Translator = function (tVariableTarget) {
this.setDebug = function (tValue) {
this.pDebug = tValue;
};
this.getDebug = function () {
return(this.pDebug);
};
this.valueFromLevel0 = function (tObject) {
var tValue = "";
if (String(typeof(tObject)).toUpperCase() == "OBJECT") {
if (_level0[tObject.targetName][tObject.variableName] != undefined) {
tValue = _level0[tObject.targetName][tObject.variableName];
} else {
tValue = tObject.defaultValue;
}
} else {
tValue = tObject;
}
return(tValue);
};
this.setLang = function (tObject) {
this.pLang = String(this.valueFromLevel0(tObject)).toLowerCase();
};
this.getLang = function () {
return(this.pLang);
};
this.setLangGroup = function (tValue) {
this.pLangGroup = String(tValue).toLowerCase();
};
this.getLangGroup = function () {
if (this.pLangGroup == undefined) {
var tWesternLang_array = ["en", "pt", "de", "fr", "it", "es"];
var tLangGroup_str = String("nw");
for (var i in tWesternLang_array) {
if (this.getLang().toUpperCase() == tWesternLang_array[i].toUpperCase()) {
tLangGroup_str = "we";
break;
}
}
this.pLangGroup = String(tLangGroup_str).toLowerCase();
}
return(this.pLangGroup);
};
this.setTypeID = function (tObject) {
this.pTypeID = Number(this.valueFromLevel0(tObject));
};
this.getTypeID = function () {
return(this.pTypeID);
};
this.setItemID = function (tObject) {
this.pItemID = Number(this.valueFromLevel0(tObject));
};
this.getItemID = function () {
return(this.pItemID);
};
this.setPlayMode = function (tValue) {
this.pPlayMode = String(tValue).toUpperCase();
};
this.getPlayMode = function () {
return(this.pPlayMode);
};
this.setReturnFormat = function (tValue) {
this.pReturnFormat = tValue;
};
this.getReturnFormat = function () {
return(this.pReturnFormat);
};
this.setTranslationBaseURL = function (tValue) {
this.pTranslationBaseURL = tValue;
};
this.getTranslationBaseURL = function () {
return(this.pTranslationBaseURL);
};
this.setTarget = function (tValue) {
this.pTarget = tValue;
};
this.getTarget = function () {
return(this.pTarget);
};
this.setVariableList = function (tValue) {
this.pIDSVars = tValue;
};
this.getVariableList = function () {
return(this.pIDSVars);
};
this.getTranslationURL = function () {
var tURL = this.getTranslationBaseURL();
return(tURL);
};
this.oTrace = function (tMessageString) {
if (this.getDebug()) {
trace("TRANSLATOR: " + tMessageString);
}
};
this.setDebug(tVariableTarget.debug);
this.setLang(tVariableTarget.lang);
this.setTypeID(tVariableTarget.typeID);
this.setItemID(tVariableTarget.itemID);
this.setPlayMode(tVariableTarget.playMode);
this.setTranslationScriptURL(tVariableTarget.translationScriptURL);
this.setReturnFormat("XML");
this.setTarget(tVariableTarget._parent);
if (this.getDebug() == true) {
this.setTranslationBaseURL("http://dev.neopets.com/transcontent/gettranslationxml.phtml");
this.otrace(("CALLING DEV.(" + this.getTranslationBaseURL()) + ") SET DEBUG=FALSE BEFORE LAUNCH");
} else {
this.setTranslationBaseURL("http://www.neopets.com/transcontent/gettranslationxml.phtml");
}
EventBroadcaster.initialize(this);
this.addListener(this);
this.onLoad = function (tSuccess) {
};
if (this.getPlayMode() == "AUTOMATIC") {
this.toggleTargetPlayMode(false);
this.translate();
}
};
Translator.prototype.toggleTargetPlayMode = function (tPlayMode_b) {
if (tPlayMode_b == true) {
_root[this.getTarget()].play();
} else {
_root[this.getTarget()].stop();
}
};
Translator.prototype.translate = function () {
this.translateToTarget(this.getTarget());
};
Translator.prototype.translateToTarget = function (tTarget) {
this.setTarget(tTarget);
tConnection_lv = new LoadVars();
tConnection_lv.translator = this;
tConnection_lv.onLoad = function (tSuccess_b) {
this.translator.broadcastMessage("onLoad", tSuccess_b);
};
tConnection_lv.onData = function (tXML_str) {
this.translator.oTrace("onData()");
var tTranslation_xml = new XML();
tTranslation_xml.ignoreWhite = true;
tTranslation_xml.parseXML(tXML_str);
if (tTranslation_xml.firstChild.nodeName.toUpperCase() == "XLIFF") {
this.translator.translateXML(tTranslation_xml);
this.onLoad(true);
} else {
this.onLoad(false);
}
};
tConnection_lv.randomNumber = random(9999999);
tConnection_lv.lang = this.getLang();
tConnection_lv.type_id = this.getTypeID();
tConnection_lv.item_id = this.getItemID();
this.oTrace("sendAndLoad()");
this.oTrace("\t URL: " + this.getTranslationURL());
this.oTrace("\tpost: " + tConnection_lv.toString());
tConnection_lv.sendAndLoad(this.getTranslationURL(), tConnection_lv);
};
Translator.prototype.translateXML = function (tTranslation_xml) {
var tXLIFF_xml = tTranslation_xml.firstChild;
var tFile_xml = tTranslation_xml.firstChild.firstChild;
var tTransVarList = new Array();
var transVar = function (tName, tValue) {
this.name = tName;
this.value = tValue;
this.oTrace((this.name + " = ") + this.value);
};
var l = tFile_xml.childNodes.length;
t = 0;
while (t < l) {
var tSectionNode = tFile_xml.childNodes[t];
if (tSectionNode.nodeName.toUpperCase() == "HEADER") {
} else if (tSectionNode.nodeName.toUpperCase() == "BODY") {
var tSectionLength = tSectionNode.childNodes.length;
var sl = 0;
while (sl < tSectionLength) {
var tUnitNode = tSectionNode.childNodes[sl];
var tSourceText = tUnitNode.firstChild.firstChild;
tTransVarList.push(new transVar(tUnitNode.attributes.resname.toString(), tSourceText.toString()));
sl++;
}
}
t++;
}
this.copyVariablesToLocal(tTransVarList);
var tTarget = this.getTarget();
var tVariableList = this.getVariableList();
this.copyVariablesToTarget(tTarget, tVariableList);
};
Translator.prototype.copyVariablesToLocal = function (tTransVarList) {
var tIDSVars = Object();
this.oTrace("copyVariablesToLocal()");
var tLength_num = tTransVarList.length;
var prop = 0;
while (prop < tLength_num) {
tIDSVars[String(tTransVarList[prop].name)] = unescape(String(tTransVarList[prop].value));
this.oTrace("\tvariable #" + prop);
this.oTrace("\t\tname: " + String(tTransVarList[prop].name));
this.oTrace("\t\tvalue: " + tIDSVars[String(tTransVarList[prop].name)]);
prop++;
}
this.setVariableList(tIDSVars);
};
Translator.prototype.copyVariablesToTarget = function (tTarget, tVariableList) {
for (var prop in tVariableList) {
tTarget[prop] = tVariableList[prop];
}
if (this.getPlayMode() == "AUTOMATIC") {
this.toggleTargetPlayMode(true);
this.setPlayMode("MANUAL");
}
};
TranslatorManager = function () {
if (_global.NPTranslator == undefined) {
tVariableTarget = this;
_global.NPTranslator = new Translator(tVariableTarget);
}
this = _global.NPTranslator;
};
Object.registerClass("NPTranslator", TranslatorManager);
#endinitclip
this._visible = 0;
stop();
Symbol 19 MovieClip [__Packages.ComicBookShell] Frame 0
class ComicBookShell
{
var page_mc, pPageCurrent_num, pageMin_num, pageMax_num, embedFonts_boolean, pageLoader_mcl, page, previous_mc, next_mc, previous_btn, next_btn, title_txt, title_str;
function ComicBookShell () {
trace("ComicBookShell()");
page_mc = _root.comicBookMold_mc;
if (_global.NPTranslator.getLangGroup().toUpperCase() == "WE") {
setEmbedFonts(true);
} else {
setEmbedFonts(false);
}
}
function get pageCurrent_num() {
return(pPageCurrent_num);
}
function set pageCurrent_num(tValue) {
var tInactiveAlpha_num = 50;
if (tValue <= pageMin_num) {
pPageCurrent_num = pageMin_num;
getNextMC()._alpha = 100;
getNextButton().enabled = true;
getPreviousMC()._alpha = tInactiveAlpha_num;
getPreviousButton().enabled = false;
} else if (tValue >= pageMax_num) {
pPageCurrent_num = pageMax_num;
getNextMC()._alpha = tInactiveAlpha_num;
getNextButton().enabled = false;
getPreviousMC()._alpha = 100;
getPreviousButton().enabled = true;
} else {
getNextMC()._alpha = 100;
getNextButton().enabled = true;
getPreviousMC()._alpha = 100;
getPreviousButton().enabled = true;
pPageCurrent_num = tValue;
}
trace(pPageCurrent_num);
//return(pageCurrent_num);
}
function setXML(tXML_str) {
pages_array = [];
var tComic_xml = new XML(tXML_str);
var tMessage_xml = tComic_xml.firstChild;
if (tMessage_xml.attributes.success == "1") {
var tPages_xml = tMessage_xml.firstChild.firstChild.firstChild;
trace(tPages_xml);
var tPage_num = 0;
while (tPage_num < tPages_xml.childNodes.length) {
var tPage_xml = tPages_xml.childNodes[tPage_num];
var tPage = new Object();
trace(tPage_xml);
var tProp_num = 0;
while (tProp_num < tPage_xml.childNodes.length) {
var tProp_xml = tPage_xml.childNodes[tProp_num];
var tName_str = tProp_xml.nodeName.toString();
var tValue_str = tProp_xml.firstChild.toString();
tPage[tName_str] = tValue_str;
tProp_num++;
}
pages_array.push(tPage);
tPage_num++;
}
} else {
trace("load error");
}
trace("setting #'s");
pageMin_num = 0;
pageMax_num = pages_array.length - 1;
}
function init() {
selectPage(0);
initText();
}
function setEmbedFonts(tValue) {
embedFonts_boolean = Boolean(tValue);
}
function getEmbedFonts() {
return(embedFonts_boolean);
}
function initText() {
getPreviousMC().previousPage_txt.html = true;
getPreviousMC().previousPage_txt.embedFonts = getEmbedFonts();
getNextMC().nextPage_txt.html = true;
getNextMC().nextPage_txt.embedFonts = getEmbedFonts();
}
function selectPage(tPage_num) {
pageCurrent_num = (tPage_num);
showPage(pages_array[pageCurrent_num]);
}
function selectNextPage() {
pageCurrent_num = ((pageCurrent_num+1));
showPage(pages_array[pageCurrent_num]);
}
function selectPreviousPage() {
pageCurrent_num = ((pageCurrent_num-1));
showPage(pages_array[pageCurrent_num]);
}
function showPage(tPage) {
trace("showing page with number of " + tPage.number);
setTitleString("");
var tPageLoaderListener = new Object();
tPageLoaderListener.comicBookShell = this;
tPageLoaderListener.onLoadStart = function (tTarget_mc) {
tTarget_mc._visible = 0;
};
tPageLoaderListener.onLoadProgress = function (tTarget_mc, tBytesLoaded_num, tBytesTotal_num) {
tTarget_mc._visible = 0;
var p = int((100 * tBytesLoaded_num) / tBytesTotal_num);
this.comicBookShell.setTitleString(p + "%");
};
tPageLoaderListener.onLoadComplete = function (tTarget_mc) {
this.comicBookShell.setTitleString("100%");
};
tPageLoaderListener.onLoadInit = function (tTarget_mc) {
tTarget_mc._visible = 1;
trace("yeah## " + this.comicBookShell.pages_array[this.comicBookShell.pageCurrent_num].number);
this.comicBookShell.initPage(tTarget_mc, this.comicBookShell.pages_array[this.comicBookShell.pageCurrent_num].number);
};
pageLoader_mcl = new MovieClipLoader();
pageLoader_mcl.addListener(tPageLoaderListener);
pageLoader_mcl.loadClip(tPage.url, page_mc);
}
function initPage(tTarget_mc, tTextNumber) {
var tBook_num = 0;
page = new ComicPage(this, tTarget_mc, tBook_num, pageCurrent_num, tTextNumber);
}
function setPreviousMC(tValue) {
previous_mc = tValue;
}
function getPreviousMC() {
return(previous_mc);
}
function setNextMC(tValue) {
next_mc = tValue;
}
function getNextMC(tValue) {
return(next_mc);
}
function setPreviousButton(tValue) {
previous_btn = tValue;
previous_btn.comicBookShell = this;
previous_btn.onRollOver = function () {
this.comicBookShell.page.setHightlightForAllPanels(1);
};
previous_btn.onPress = function () {
this.comicBookShell.selectPreviousPage();
};
}
function getPreviousButton() {
return(previous_btn);
}
function setNextButton(tValue) {
next_btn = tValue;
next_btn.comicBookShell = this;
next_btn.onRollOver = function () {
this.comicBookShell.page.setHightlightForAllPanels(1);
};
next_btn.onPress = function () {
this.comicBookShell.selectNextPage();
};
}
function getNextButton() {
return(next_btn);
}
function setTitleText(tValue) {
title_txt = tValue;
title_txt.html = true;
}
function setTitleString(tValue) {
title_str = tValue;
if (title_str != undefined) {
var tIndexInfo_str = "";
tIndexInfo_str = tIndexInfo_str + newline;
tIndexInfo_str = tIndexInfo_str + (((((("<font size = '12'>(" + (1 + pageCurrent_num)) + "/") + (pageMax_num + 1)) + ") #") + pages_array[pPageCurrent_num].number) + "</font>");
title_txt.embedFonts = getEmbedFonts();
title_txt.multiline = false;
title_txt.htmlText = (("<p align='center'><font size = '20' color='#84772F'>" + title_str) + tIndexInfo_str) + "</font></p>";
} else {
title_txt.htmlText = "";
}
}
var pages_array = [];
}
Symbol 20 MovieClip [__Packages.ComicPage] Frame 0
class ComicPage
{
var comicBookShell, book_num, page_num, text_num, mc;
function ComicPage (tComicBookShell, tTarget_mc, tBook_num, tPage_num, tText_num) {
trace("ComicPage(): " + tTarget_mc);
comicBookShell = tComicBookShell;
book_num = tBook_num;
page_num = tPage_num;
text_num = tText_num;
mc = tTarget_mc;
initBG();
initPanels();
}
function initBG() {
mc.bg0_mc.useHandCursor = false;
mc.bg0_mc.comicPage = this;
mc.bg0_mc.onRollOver = function () {
var tInterval_num = 250;
this.comicPage.highlightIntervalID_num = setInterval(this.comicPage.setHightlightForAllPanelsInterval, tInterval_num, this.comicPage, 1);
};
mc.bg0_mc.onRollOut = function () {
clearInterval(this.comicPage.highlightIntervalID_num);
};
}
function setHightlightForAllPanelsInterval(tTarget, tState_boolean) {
tTarget.setHightlightForAllPanels(tState_boolean);
clearInterval(tTarget.highlightIntervalID_num);
}
function setHightlightForAllPanels(tState_boolean) {
for (var tPanel in panels_array) {
panels_array[tPanel].setHighlight(tState_boolean);
}
}
function initPanels() {
var i = 0;
while (i < 20) {
for (var t in mc) {
}
var tPanel_mc = mc[("panel" + i) + "_mc"];
var tText_mc = mc[("text" + i) + "_mc"];
if (tPanel_mc != undefined) {
var tPanel = new ComicPanel(this, tPanel_mc, tText_mc, book_num, text_num, i);
panels_array.push(tPanel);
}
i++;
}
}
var panels_array = [];
}
Symbol 21 MovieClip [__Packages.ComicPanel] Frame 0
class ComicPanel
{
var comicPage, book_num, page_num, index_num, panel_mc, text_mc, panel_color, panel_cxForm, lastTweenInterval;
function ComicPanel (tComicPage, tPanel_mc, tText_mc, tBook_num, tPage_num, tPanel_num) {
comicPage = tComicPage;
book_num = tBook_num;
page_num = tPage_num;
index_num = tPanel_num;
panel_mc = tPanel_mc;
text_mc = tText_mc;
initPanel();
initText();
}
function initPanel() {
setSelected(0);
setShowText(0);
panel_color = new Color(panel_mc);
panel_cxForm = new Object();
panel_mc.comicPanel = this;
panel_mc.onRollOver = function () {
this.comicPanel.comicPage.setHightlightForAllPanels(0);
this.comicPanel.setSelected(1);
};
panel_mc.onRollOut = function () {
this.comicPanel.setShowText(0);
};
}
function setSelected(tState_boolean) {
setHighlight(tState_boolean);
setShowText(tState_boolean);
}
function setShowText(tState_boolean) {
if (tState_boolean == true) {
text_mc._visible = 1;
var tMC = text_mc;
var tPropertyName = "_alpha";
var tVal1_num = 10;
var tVal2_num = 100;
var tIncrement_num = 50;
var interval = 20;
tweenProperty(tMC, tPropertyName, tVal1_num, tVal2_num, tIncrement_num, interval);
} else {
text_mc._visible = 0;
clearInterval(lastTweenInterval);
}
}
function setHighlight(tState_boolean) {
if (tState_boolean == true) {
var tLight_num = 100;
panel_cxForm.ra = tLight_num;
panel_cxForm.rb = 0;
panel_cxForm.ga = tLight_num;
panel_cxForm.gb = 0;
panel_cxForm.ba = tLight_num;
panel_cxForm.bb = 0;
panel_cxForm.aa = 100;
panel_cxForm.ab = 0;
} else {
var tLight_num = 50;
panel_cxForm.ra = tLight_num;
panel_cxForm.rb = 0;
panel_cxForm.ga = tLight_num;
panel_cxForm.gb = 0;
panel_cxForm.ba = tLight_num;
panel_cxForm.bb = 0;
panel_cxForm.aa = 100;
panel_cxForm.ab = 0;
}
panel_color.setTransform(panel_cxForm);
}
function tweenPropertyInterval(tComicPanel, tMC, tPropertyName, tVal1_num, tVal2_num, tIncrement_num) {
if (tMC[tPropertyName] < tVal2_num) {
tMC[tPropertyName] = int(tMC[tPropertyName] + tIncrement_num);
} else {
tMC[tPropertyName] = tVal2_num;
clearInterval(tComicPanel.lastTweenInterval);
}
}
function tweenProperty(tMC, tPropertyName, tVal1_num, tVal2_num, tIncrement_num, interval) {
tMC[tPropertyName] = tVal1_num;
lastTweenInterval = setInterval(tweenPropertyInterval, interval, this, tMC, tPropertyName, tVal1_num, tVal2_num, tIncrement_num);
}
function initText() {
var i = 0;
while (i < MAX_BUBBLES_NUM) {
var tVar_str = ((((((("IDS_BOOK" + book_num) + "_PAGE") + page_num) + "_TEXT") + index_num) + "_BUBBLE") + i);
var tText_str = _root[tVar_str];
var tText_txt = text_mc[("bubble" + i) + "_txt"];
if (tText_txt != undefined) {
tText_txt.embedFonts = comicPage.comicBookShell.getEmbedFonts();
tText_txt.html = true;
tText_txt.htmlText = tText_str;
}
i++;
}
}
var MAX_BUBBLES_NUM = 10;
}