//Copyright University of Nottingham / Julian Tenney 2008
//Released under the GNU Public License
Stage.align = "TL";
Stage.scaleMode = "noScale";
import mx.managers.PopUpManager;
import mx.containers.Window;
mdminit();
mdm.Application.sendToBack();
editor = this;
editor.FileLocation = editor.templatePath = "";
editor.modelsFolder = ""; //default browse for opening / saving models
editor.filesFolder = ""; //default browse for opening / saving files
editor.importFolder = "";
var heightError = mdm.Forms.preview.height - 600;
var widthError = mdm.Forms.preview.width - 800;
editor.windowWidth = Number(mdm.Forms.MainForm.width);
editor.windowHeight = Number(mdm.Forms.MainForm.height);
editor.windowWidthError = Number(mdm.Forms.MainForm.width - Stage.width);
editor.windowHeightError = Number(mdm.Forms.MainForm.height - Stage.height);
mdm.Application.onFormMaximize = function(obj){
resizeWindow(obj.width,obj.height);
}
mdm.Application.onFormResize = function(obj){
clearInterval(resizeID);
resizeID = setInterval(resizeComplete, 0, obj.width, obj.height);
}
function resizeComplete(w,h){
clearInterval(resizeID);
resizeWindow(mdm.Forms.MainForm.width,mdm.Forms.MainForm.height);
}
mdm.Application.onFormRestore = function(obj){
resizeWindow(obj.width,obj.height);
}
function resizeWindow(w,h){
editor.windowWidth = Number(w);
editor.windowHeight = Number(h);
menuBar.setSize(w - windowWidthError, 22);
tree.setSize(tree.width, h - windowHeightError - 22);
accord.setSize(w - tree.width - 3, h - windowHeightError - 22);
//resize the accordion contents:
accord.propPane.propEdit.setSize(w - splitter._x - 3 - windowWidthError, h - 88 - windowHeightError);
accord.textPane.textEdit.setSize(w - splitter._x - 3 - windowWidthError, h - 88 - windowHeightError);
accord.codePane.codeEdit.setSize(w - splitter._x - 3 - windowWidthError, h - 88 - windowHeightError);
}
mdm.Application.textAreaEnhance(true);
//used by fscommand to return values... watches variables for changes
function CEvents(){
this.addProperty("fileName", this.getFile, this.setFile);
this.addProperty("newFileName", this.getNewFileName, this.setNewFileName);
//called when file dropped, File -> New; command line
this.addProperty("modelFileSave", this.getModelFileSave, this.setModelFileSave);
this.addProperty("modelFileOpen", this.getModelFileOpen, this.setModelFileOpen);
this.addProperty("fileExists", this.getFileExists, this.setFileExists);
this.addProperty("overwrite", this.getOverwrite, this.setOverwrite);
this.addProperty("cmd", this.getCmd, this.setCmd);
this.addProperty("templateFile", this.getTem, this.setTem);
this.addProperty("packageFile", this.getPackage, this.setPackage);
}
CEvents.prototype.getPackage = function() {
/*not used */
};
CEvents.prototype.setPackage = function(value) {
var packageFile = value;
if (packageFile != 'false') {
//create the path
if (packageFile.indexOf('.zip') == -1) {
packageFile += '.zip';
}
//get fileLoc (the dir where the project is)
var fileLoc = editor.FileLocation.substr(0, editor.FileLocation.lastIndexOf('\\')+1);
//runtime files
mdm.copyfile(launchPath+'publish\\common\\MainPreloader.swf', fileLoc+'MainPreloader.swf');
mdm.copyfile(launchPath+'publish\\common\\XMLEngine.swf', fileLoc+'XMLEngine.swf');
if (!mdm.FileSystem.fileExists(fileLoc+'resources.swf')){
mdm.copyfile(launchPath+'publish\\common\\resources.swf', fileLoc+'resources.swf');
}
mdm.copyfile(launchPath+'publish\\scorm1.2\\flash.js', fileLoc+'flash.js');
mdm.copyfile(launchPath+'publish\\scorm1.2\\apiwrapper.js', fileLoc+'apiwrapper.js');
//scorm xml
mdm.copyfile(launchPath+'publish\\scorm1.2\\imsmd_rootv1p2p1.xsd', fileLoc+'imsmd_rootv1p2p1.xsd');
mdm.copyfile(launchPath+'publish\\scorm1.2\\imscp_rootv1p1p2.xsd', fileLoc+'imscp_rootv1p1p2.xsd');
mdm.copyfile(launchPath+'publish\\scorm1.2\\ims_xml.xsd', fileLoc+'ims_xml.xsd');
mdm.copyfile(launchPath+'publish\\scorm1.2\\adlcp_rootv1p2.xsd', fileLoc+'adlcp_rootv1p2.xsd');
//manifest - need three IDs: Organisation, Item and Resource
var strID = String(new Date().getTime());
var orgID = "ACME-ORG-"+strID;
var itemID = "ACME-ITEM-"+strID;
var resID = "ACME-RES-"+strID;
//a simple manifest
var manifestFileString = '\r';
manifestFileString += '';
manifestFileString += 'ADL SCORM1.2\r';
manifestFileString += '\r';
manifestFileString += '\r';
manifestFileString += ''+contentXML.firstChild.getChildByNodeName('IFC').attributes.name+'\r';
manifestFileString += '- \r';
manifestFileString += ''+contentXML.firstChild.getChildByNodeName('IFC').attributes.title+'\r';
manifestFileString += '
\r\r\r';
manifestFileString += '\r';
manifestFileString += '\r';
manifestFileString += '\r';
manifestFileString += '\r';
manifestFileString += '\r';
manifestFileString += '\r';
manifestFileString += '\r';
manifestFileString += '\r';
manifestFileString += '';
mdm.FileSystem.saveFile(editor.FileLocation.substr(0, editor.FileLocation.lastIndexOf('\\')+1)+'imsmanifest.xml', manifestFileString);
//hosting html file, based on scormRLO.htm
//get filename (.e. 'file.rlo')
var fileName = editor.FileLocation.substr(editor.FileLocation.lastIndexOf('\\')+1, editor.FileLocation.length);
//read in template scormRLO.htm
var SCOLoaderHTML = mdm.FileSystem.loadFile(launchPath+'publish\\scorm1.2\\scormRLO.htm');
//replace the %FILE% tokens in the file
var finalHTML = replace(SCOLoaderHTML, '%FILE%', fileName);
//if stage coords are set,
if (contentXML.firstChild.attributes.stageSize != undefined){
var stageCoords = contentXML.firstChild.attributes.stageSize.split(',');
finalHTML = replace(finalHTML, '%WIDTH%', stageCoords[0]);
finalHTML = replace(finalHTML, '%HEIGHT%', stageCoords[1]);
} else { //use the default
finalHTML = replace(finalHTML, '%WIDTH%', '800');
finalHTML = replace(finalHTML, '%HEIGHT%', '600');
}
var htmlFileName = 'scormRLO.htm';
if (Key.isDown(Key.CONTROL)){
htmlFileName = mdm.Dialogs.inputBox("HTML File Name", "Enter the HTML File Name Here:");
}
if (htmlFileName.indexOf('.htm') == -1) htmlFileName += '.htm';
//write the file
mdm.FileSystem.saveFile(fileLoc+htmlFileName, finalHTML);
//zip the folder and save
var destZip = packageFile;
var sourceFolder = editor.FileLocation.substr(0, editor.FileLocation.lastIndexOf('\\') + 1);
var fsparams = '"'+packageFile+"\",\""+sourceFolder+"\",\"*.*\",\"none\"";
fscommand("flashvnn.ZipFolder", fsparams);
fscommand("flashvnn.CloseZip", "");
mdm.prompt("Packaging complete. SCORM compliant package created.");
}
};
CEvents.prototype.getTem = function() {
/*not used */
};
CEvents.prototype.setTem = function(value) {
if (value != 'false') {
var saveTemplatePath = value;
if (saveTemplatePath.indexOf('.xml') == -1) {
saveTemplatePath += '.xml';
}
mdm.copyfile(editor.modelFile.substr(0, editor.modelFile.lastIndexOf('.'))+'.xml', saveTemplatePath);
//now write the file property to templateData attribute of XML
//replace path with FileLocation string - file must be saved within FileLocation dir for now...
var fileLoc = editor.FileLocation.substr(0, editor.FileLocation.lastIndexOf('\\')+1);
modelXML.firstChild.attributes.templateData = replace(saveTemplatePath, fileLoc, "FileLocation + '")+"'";
//add support for supporting files here (files the KO will need to operate)
//we need to know where the user chose the model from
templateXML = new XML();
templateXML.load(editor.modelFile.substr(0, editor.modelFile.lastIndexOf('.'))+'.xml');
templateXML.onLoad = function() {
if (this.firstChild.attributes.files != undefined) {
//we have files to copy
var filesArray = this.firstChild.attributes.files.split(',');
if (!mdm.FileSystem.folderExists(fileLoc+'\\supportFiles')) {
mdm.FileSystem.makeFolder(fileLoc+'\\supportFiles');
}
for (var i = 0; i');
} else {
contentXML = new XML('');
}
contentXML.ignoreWhite = true;
tree.dataProvider = contentXML;
//****give the new XML object the onload function
//****this is duplicated code from the original but *is* needed
//as the contentXML object has been recreated and it loses the handler - this is exactly the same
contentXML.onLoad = function() {
tree.dataProvider = this;
//format CDATA code nodes - remove extraneous newlines...
formatCodeNodes(this.firstChild);
tree.selectedNode = tree.getTreeNodeAt(0);
//get keywords off the BIN icon
keywords.clear();
for (var i in this.firstChild.lastChild.attributes){
if (i != 'name'){
keywords.addWord(i, this.firstChild.lastChild.attributes[i]);
}
}
//show the properties...
var atts = tree.selectedItem.attributes;
//refresh them first...
accord.propPane.propEdit.removeAll();
for (var i in atts) {
var obj = {Property:i, Value:atts[i]};
accord.propPane.propEdit.addItem(obj);
}
//make the combobox
makeComboMenu(tree.selectedItem.nodeName, tree.selectedItem.attributes.type);
//check for a bin and make one...
if (value.indexOf('.rlm') == -1){
if (contentXML.firstChild.lastChild.nodeName != 'BIN') {
var tempNode = new XML('');
contentXML.firstChild.appendChild(tempNode.firstChild);
}
}
if (this.fileName.indexOf('.rla') != -1){
playApplication();
}
if (this.fileName.indexOf('.rlt') != -1){
runKOWizard()
}
tree.setIsOpen(tree.getTreeNodeAt(0), true);
//find the interface icon to open
var lo = tree.getTreeNodeAt(0);
for (var i = 0; i < lo.childNodes.length; i++){
if (lo.childNodes[i].nodeName == 'IFC'){
tree.setIsOpen(lo.childNodes[i], true);
}
}
};
this.action = "";
}
//make the new XML file...
if (newFileName.indexOf('.rlo') == -1 && newFileName.indexOf('.rlm') == -1 && newFileName.indexOf('.rlt') == -1) {
newFileName += '.rlo';
}
this.tempFileName = newFileName;
mdm.Application.title = newFileName.substring(newFileName.lastIndexOf('\\') + 1, newFileName.length);
mdm.fileexists(newFileName, "events.fileExists");
}
};
CEvents.prototype.getFileExists = function() {
/*not used*/
};
CEvents.prototype.setFileExists = function(value) {
if (value == "false") {
makeNewFile(this.tempFileName);
} else {
mdm.prompt_adv("The file "+this.tempFileName+" already exists.\rDo you want to replace it?", "alert", "events.overwrite");
}
};
CEvents.prototype.getOverwrite = function() {
/*not used*/
};
CEvents.prototype.setOverwrite = function(value) {
if (value == "true") {
makeNewFile(this.tempFileName);
} else {
//do nothing
}
};
CEvents.prototype.getCmd = function() {
/*not used*/
};
//gets command line filenames
CEvents.prototype.setCmd = function(value) {
if (value != "" && value != undefined) {
events.fileName = value;
}
};
CEvents.prototype.getModelFileSave = function() {
/* not used */
};
CEvents.prototype.setModelFileSave = function(value) {
if (value != 'false') {
modelFile = value;
editor.modelsFolder = value.substr(0, value.lastIndexOf("\\") + 1);
if (modelFile.indexOf('.rlm') == -1) {
modelFile += '.rlm';
}
saveModel(modelFile);
}
};
CEvents.prototype.getModelFileOpen = function() {
/* not used */
};
CEvents.prototype.setModelFileOpen = function(value) {
if (value != 'false') {
modelFile = value;
editor.modelsFolder = value.substr(0, value.lastIndexOf("\\") + 1);
insertModel(modelFile);
}
};
function getFileName(value) {
//mdm.prompt("here we are files");
if (value.toLowerCase() != 'false') {
if (value.toLowerCase().indexOf('.rlo') != -1) {
editor.filesFolder = value.substr(0, value.lastIndexOf("\\") + 1);
contentXML.fileName = value;
editor.FileLocation = editor.templatePath = contentXML.fileName;
mdm.setwindowtitle('XERTE '+ contentXML.fileName);
mdm.Application.title = contentXML.fileName.substring(contentXML.fileName.lastIndexOf('\\') + 1, contentXML.fileName.length);
contentXML.ignoreWhite = true;
contentXML.load(value);
//if there is a resources.swf, copy it to the app dir
var parentFolder = editor.filesFolder.substr(0,editor.filesFolder.length - 2);
parentFolder = parentFolder.substr(0, parentFolder.lastIndexOf('\\') + 1);
if (mdm.FileSystem.fileExists(editor.filesFolder+'resources.swf')){
//use the resources file from the rlo file's directory
mdm.copyfile(editor.filesFolder+'resources.swf', launchPath+'resources.swf');
} else if (mdm.FileSystem.fileExists(parentFolder+'resources.swf')){
//check the parent folder, because this might be a project that shares a runtime
mdm.copyfile(parentFolder+'resources.swf', launchPath+'resources.swf');
} else {
//use the empty one from the scorm folder, which will be added to the directory when published
mdm.copyfile(launchPath+'publish\\common\\resources.swf', launchPath+'resources.swf');
}
} else if (value.toLowerCase().indexOf('.rla') != -1) {
contentXML.fileName = value;
editor.FileLocation = editor.templatePath = contentXML.fileName;
contentXML.ignoreWhite = true;
contentXML.load(value);
} else if (value.toLowerCase().indexOf('.rlm') != -1) {
editor.filesFolder = value.substr(0, value.lastIndexOf("\\") + 1);
contentXML.fileName = value;
editor.FileLocation = editor.templatePath = contentXML.fileName;
mdm.setwindowtitle('XERTE '+ contentXML.fileName);
mdm.Application.title = contentXML.fileName.substring(contentXML.fileName.lastIndexOf('\\') + 1, contentXML.fileName.length);
contentXML.ignoreWhite = true;
contentXML.load(value);
} else if (value.toLowerCase().indexOf('.rlt') != -1) {
editor.filesFolder = value.substr(0, value.lastIndexOf("\\") + 1);
contentXML.fileName = value;
editor.FileLocation = editor.templatePath = contentXML.fileName;
mdm.setwindowtitle('XERTE '+ contentXML.fileName);
mdm.Application.title = contentXML.fileName.substring(contentXML.fileName.lastIndexOf('\\') + 1, contentXML.fileName.length);
contentXML.ignoreWhite = true;
contentXML.load(value);
//if there is a resources.swf, copy it to the app dir
var parentFolder = editor.filesFolder.substr(0,editor.filesFolder.length - 2);
parentFolder = parentFolder.substr(0, parentFolder.lastIndexOf('\\') + 1);
if (mdm.FileSystem.fileExists(editor.filesFolder+'resources.swf')){
//use the resources file from the rlo file's directory
mdm.copyfile(editor.filesFolder+'resources.swf', launchPath+'resources.swf');
} else if (mdm.FileSystem.fileExists(parentFolder+'resources.swf')){
//check the parent folder, because this might be a project that shares a runtime
mdm.copyfile(parentFolder+'resources.swf', launchPath+'resources.swf');
} else {
//use the empty one from the scorm folder, which will be added to the directory when published
mdm.copyfile(launchPath+'publish\\common\\resources.swf', launchPath+'resources.swf');
}
} else if (value.toLowerCase().indexOf('.xtp') != -1){
intID = setInterval(makeTemplateProject, 1000, value);
return;
} else if (value.toLowerCase().indexOf('.xcp') != -1 && contentXML.fileName != "" && contentXML.fileName != undefined) {
insertPageTemplate(value);
} else if (value.toLowerCase().indexOf('.mxml') != -1){
mdm.Forms.flexEdit.callFunction("openMXML", value, "|");
return;
}
}
//SWF IMPORT////////////////////////////////////////////////////////////
if (value.toLowerCase().indexOf('.swf') != -1 && (tree.selectedItem.nodeName == 'PG' || tree.selectedItem.nodeName == 'RES')) {
var swfHeader = mdm.Image.getSwfHeader(value);
var w = swfHeader[0];
var h = swfHeader[1];
var frames = swfHeader[4];
swfImport._visible = true;
swfImport._x = 250;
swfImport._y = 200;
var fileName = value.substring(value.lastIndexOf('\\')+1, value.length);
var fileLoc = editor.FileLocation.substr(0, editor.FileLocation.lastIndexOf('\\')+1);
var ifcOn = Number(contentXML.firstChild.firstChild.attributes.visuals);
swfImport.init(w,h,value,fileName,fileLoc,ifcOn,frames);
}
//FLV IMPORT ///////////////////////////////////////////////////////////
if (value.toLowerCase().indexOf('.flv') != -1 && (tree.selectedItem.nodeName == 'PG' || tree.selectedItem.nodeName == 'RES')) {
///*Working on this....
flvImport._visible = true;
flvImport._x = 250;
flvImport._y = 200;
var fileName = value.substring(value.lastIndexOf('\\')+1, value.length);
var fileLoc = editor.FileLocation.substr(0, editor.FileLocation.lastIndexOf('\\')+1);
var ifcOn = Number(contentXML.firstChild.firstChild.attributes.visuals);
flvImport.init(value,fileName,fileLoc,ifcOn);
}
//JPG IMPORT///////////////////////////////////////////////////////////
if ((value.toLowerCase().indexOf('.jpg') != -1) || (value.toLowerCase().indexOf('.jpeg') != -1) && (tree.selectedItem.nodeName == 'PG' || tree.selectedItem.nodeName == 'RES')){
//get width and height
var jpgSize = mdm.Image.getJpgSize(value);
var w = jpgSize[0];
var h = jpgSize[1];
jpgImport._visible = true;
jpgImport._x = 250;
jpgImport._y = 200;
var fileName = value.substring(value.lastIndexOf('\\')+1, value.length);
var fileLoc = editor.FileLocation.substr(0, editor.FileLocation.lastIndexOf('\\')+1);
var ifcOn = Number(contentXML.firstChild.firstChild.attributes.visuals);
jpgImport.init(w,h,value,fileName,fileLoc,ifcOn);
}
//PNG IMPORT///////////////////////////////////////////////////////////
if (value.toLowerCase().indexOf('.png') != -1 && (tree.selectedItem.nodeName == 'PG' || tree.selectedItem.nodeName == 'RES')){
//convert to a swf for dimensions...
mdm.Image.pngToSwf(value);
var swfFile = value.split('.png').join('.swf');
var swfHeader = mdm.Image.getSwfHeader(swfFile);
var w = swfHeader[0];
var h = swfHeader[1];
//delete the swf
mdm.FileSystem.deleteFile(swfFile);
pngImport._visible = true;
pngImport._x = 250;
pngImport._y = 200;
var fileName = value.substring(value.lastIndexOf('\\')+1, value.length);
var fileLoc = editor.FileLocation.substr(0, editor.FileLocation.lastIndexOf('\\')+1);
var ifcOn = Number(contentXML.firstChild.firstChild.attributes.visuals);
pngImport.init(w,h,value,fileName,fileLoc,ifcOn);
}
//handle import to icon as well as the page
if ((value.toLowerCase().indexOf('.jpg') != -1 || value.toLowerCase().indexOf('.swf') != -1 || value.toLowerCase().indexOf('.png') != -1) && tree.selectedItem.nodeName == 'DIS') {
var fileLoc = editor.FileLocation.substr(0, editor.FileLocation.lastIndexOf('\\')+1);
var fileName = value.substring(value.lastIndexOf('\\')+1, value.length);
if (!mdm.FileSystem.folderExists(fileLoc+'\\media')) {
mdm.FileSystem.makeFolder(fileLoc+'\\media');
}
mdm.copyfile(value, fileLoc+'\\media\\'+fileName);
tree.selectedNode.attributes.url = "FileLocation + \'media/" + fileName;
tree.dispatchEvent({type:"change", target:tree});
}
//drop controllers for buttons
if ((value.toLowerCase().indexOf('.swf') != -1 || value.toLowerCase().indexOf('.png') != -1 || value.toLowerCase().indexOf('.jpg') != -1)&& tree.selectedItem.nodeName == 'RES' && tree.selectedItem.attributes.type == 'button') {
var fileLoc = editor.FileLocation.substr(0, editor.FileLocation.lastIndexOf('\\')+1);
var fileName = value.substring(value.lastIndexOf('\\')+1, value.length);
if (!mdm.FileSystem.folderExists(fileLoc+'\\media')) {
mdm.FileSystem.makeFolder(fileLoc+'\\media');
}
mdm.copyfile(value, fileLoc+'\\media\\'+fileName);
tree.selectedNode.attributes.swf = "FileLocation + \'media/" + fileName;
tree.dispatchEvent({type:"change", target:tree});
}
if (value.toLowerCase().indexOf('.bmp') != -1 && (tree.selectedItem.nodeName == 'PG' || tree.selectedItem.nodeName == 'RES')) {
var fileLoc = editor.FileLocation.substr(0, editor.FileLocation.lastIndexOf('\\')+1);
var fileName = value.substring(value.lastIndexOf('\\')+1, value.length);
fileName = fileName.substr(0, fileName.indexOf('.'))+'.jpg';
if (!mdm.FileSystem.folderExists(fileLoc+'\\media')) {
mdm.FileSystem.makeFolder(fileLoc+'\\media');
}
mdm.Image.bmpToJpgAdv(value, 80);
var fileToCopy = value.substr(0, value.lastIndexOf('.bmp'))+'.jpg';
mdm.FileSystem.copyFile(fileToCopy, fileLoc+'\\media\\'+fileName);
mdm.FileSystem.deleteFile(fileToCopy);
tree.selectedItem.appendChild(new XML('').firstChild);
finishAddingNode();
}
if (value.toLowerCase().indexOf('.mp3') != -1 && (tree.selectedItem.nodeName == 'PG' || tree.selectedItem.nodeName == 'RES')) {
var fileLoc = editor.FileLocation.substr(0, editor.FileLocation.lastIndexOf('\\')+1);
var fileName = value.substring(value.lastIndexOf('\\')+1, value.length);
if (!mdm.FileSystem.folderExists(fileLoc+'\\media')) {
mdm.FileSystem.makeFolder(fileLoc+'\\media');
}
mdm.copyfile(value, fileLoc+'\\media\\'+fileName);
tree.selectedItem.appendChild(new XML('').firstChild);
finishAddingNode();
}
if (value.toLowerCase().indexOf('.mp3') != -1 && tree.selectedItem.nodeName == 'SND') {
var fileLoc = editor.FileLocation.substr(0, editor.FileLocation.lastIndexOf('\\')+1);
var fileName = value.substring(value.lastIndexOf('\\')+1, value.length);
if (!mdm.FileSystem.folderExists(fileLoc+'\\media')) {
mdm.FileSystem.makeFolder(fileLoc+'\\media');
}
mdm.copyfile(value, fileLoc+'\\media\\'+fileName);
tree.selectedNode.attributes.url = "FileLocation + \'media/" + fileName;
tree.dispatchEvent({type:"change", target:tree});
}
if (value.toLowerCase().indexOf('.txt') != -1 && (tree.selectedItem.nodeName == 'PG' || tree.selectedItem.nodeName == 'RES')) {
var textStr = mdm.FileSystem.loadFile(value);
textStr = replace(textStr, newline, '');
tree.selectedItem.appendChild(new XML('').firstChild);
finishAddingNode();
}
}
function makeNewFile(value) {
contentXML.fileName = value;
editor.FileLocation = editor.templatePath = contentXML.fileName;
mdm.setwindowtitle('XERTE '+contentXML.fileName);
saveFile();
}
_level0.events = new CEvents();
var modelFile;
var modelXML = new XML();
var modelXMLStr;
modelXML.ignoreWhite = true;
modelXML.onLoad = function(success) {
tree.selectedItem.appendChild(this.firstChild);
tree.dataProvider = tree.dataProvider;
};
var editor = this;
var helpURL;
fscommand("mdm.appdir", "launchPath");
//done fscommands interface/////////////////////////////////////
//set up editor
editor = this;
//using drag and drop tree component...
tree = dndtree.getTree();
dndtree.dragFunction = function(source){
//return true or false for draggable
if (source.nodeName == 'LO'){
return false;
}
return true;
}
dndtree.dropFunction = function(source, target){
//pg can be dropped onto fw, dec, ifc;
if ((source.nodeName == 'PG' || source.nodeName == 'KO' || source.nodeName == 'FW_ENT') && (target.nodeName == 'IFC' || target.nodeName == 'FW' || target.nodeName == 'DEC'|| target.nodeName == 'BIN')){
return true;
}
//all page children - can be dropped into res, fw_ent, pg and bin;
if ((source.nodeName == 'DIS' || source.nodeName == 'DRW' || source.nodeName == 'SCR' || source.nodeName == 'COM' || source.nodeName == 'INT' || source.nodeName == 'FW' || source.nodeName == 'DEC' || source.nodeName == 'SND' || source.nodeName == 'MOV') && (target.nodeName == 'PG' || target.nodeName == 'KO' || target.nodeName == 'RES' || target.nodeName == 'FW_ENT' || target.nodeName == 'BIN')){
return true;
}
//responses can only be dropped onto interactions;
if (source.nodeName == 'RES' && (target.nodeName == 'INT' || target.nodeName == 'BIN')){
return true;
}
return false;
}
tree.hScrollPolicy = 'on';
tree.setStyle("openDuration", 0);
tree.maxHPosition = 300;
tree.setStyle("disclosureClosedIcon", "icTreeClosed");
tree.setStyle("disclosureOpenIcon", "icTreeOpen");
tree.labelFunction = function(item) {
var str;
if (item.attributes.name != undefined) {
str = item.attributes.name;
} else {
str = item.nodeName;
}
return str;
};
tree.iconFunction = function(item) {
if (item.nodeName == 'LO') {
if (item.attributes.templateData != undefined){
return 'icLOKO';
} else {
return 'icLO';
}
}
if (item.nodeName == 'IFC') {
if (item.hasChildNodes()) {
return 'icIFC';
} else {
return 'icIFC_nc';
}
}
if (item.nodeName == 'PG') {
if (item.attributes.model != undefined){
return 'icModelPG';
}
if (item.attributes.templateData != undefined){
if (item.hasChildNodes()) {
return 'icKO';
} else {
return 'icKO_nc';
}
} else {
if (item.hasChildNodes()) {
return 'icPG';
} else {
return 'icPG_nc';
}
}
}
if (item.nodeName == 'DIS') {
if (item.attributes.type == "ext") {
return 'icDIS';
} else {
return 'icABC';
}
}
if (item.nodeName == 'DRW') {
return 'icDRW';
}
if (item.nodeName == 'SND') {
return 'icSND';
}
if (item.nodeName == 'MOV') {
return 'icMOV';
}
if (item.nodeName == 'SCR') {
return 'icSCR';
}
if (item.nodeName == 'COM') {
return 'icCOM';
}
if (item.nodeName == 'FW_ENT') {
if (item.attributes.model != undefined){
return 'icFW_ENT_Model';
}
if (item.hasChildNodes()) {
return 'icFW_ENT';
} else {
return 'icFW_ENT_nc';
}
}
if (item.nodeName == 'INT') {
if (item.hasChildNodes()) {
return 'icINT';
} else {
return 'icINT_nc';
}
}
if (item.nodeName == 'FW') {
if (item.hasChildNodes()) {
return 'icFW';
} else {
return 'icFW_nc';
}
}
if (item.nodeName == 'DEC') {
if (item.hasChildNodes()) {
return 'icDEC';
} else {
return 'icDEC_nc';
}
}
if (item.nodeName == 'BIN') {
if (item.hasChildNodes()) {
return 'icBINFull';
} else {
return 'icBIN';
}
}
//response types...
if (item.nodeName == 'RES') {
if (item.attributes.type == "label") {
return "icLab";
}
if (item.attributes.type == "button") {
if (item.hasChildNodes()) {
return 'icButton';
} else {
return 'icButton_nc';
}
}
if (item.attributes.type == "radio") {
if (item.hasChildNodes()) {
return 'icRadio';
} else {
return 'icRadio_nc';
}
}
if (item.attributes.type == "checkBox") {
if (item.hasChildNodes()) {
return 'icCheckBox';
} else {
return 'icCheckBox_nc';
}
}
if (item.attributes.type == "combo") {
if (item.hasChildNodes()) {
return 'icCbo';
} else {
return 'icCbo_nc';
}
}
if (item.attributes.type == "hotSpot") {
if (item.hasChildNodes()) {
return 'icHotSpot';
} else {
return 'icHotSpot_nc';
}
}
if (item.attributes.type == "hotObject") {
if (item.hasChildNodes()) {
return 'icHotObject';
} else {
return 'icHotObject_nc';
}
}
if (item.attributes.type == "targetArea") {
if (item.hasChildNodes()) {
return 'icTarget';
} else {
return 'icTarget_nc';
}
}
if (item.attributes.type == "textEntry") {
if (item.hasChildNodes()) {
return 'icTxt';
} else {
return 'icTxt_nc';
}
}
if (item.attributes.type == "keyPress") {
if (item.hasChildNodes()) {
return 'icKey';
} else {
return 'icKey_nc';
}
}
if (item.attributes.type == "timeLimit") {
if (item.hasChildNodes()) {
return 'icTimer';
} else {
return 'icTimer_nc';
}
}
if (item.attributes.type == "triesLimit") {
if (item.hasChildNodes()) {
return 'icTriesLimit';
} else {
return 'icTriesLimit_nc';
}
}
if (item.attributes.type == "event") {
if (item.hasChildNodes()) {
return 'icEvent';
} else {
return 'icEvent_nc';
}
}
return 'icRES';
}
};
splitter.tabEnabled = false;
splitter.onPress = function() {
this.startDrag(false, 65, 22, 930, 22);
};
splitter.onRelease = splitter.onReleaseOutside = function() {
this.stopDrag();
tree.setSize(this._x, editor.windowHeight - editor.windowHeightError - 22);
accord._x = this._x + 3;
var accW = editor.windowWidth - this._x - 3 - editor.windowWidthError;
var accH = editor.windowHeight - editor.windowHeightError - 22;
accord.setSize(accW,accH);
//resize the accordion contents:
accord.propPane.propEdit.setSize(editor.windowWidth - this._x - 3 - editor.windowWidthError, editor.windowHeight - 88 - editor.windowHeightError);
accord.textPane.textEdit.setSize(editor.windowWidth - this._x - 3 - editor.windowWidthError, editor.windowHeight - 88 - editor.windowHeightError);
accord.codePane.codeEdit.setSize(editor.windowWidth - this._x - 3 - editor.windowWidthError, editor.windowHeight - 88 - editor.windowHeightError);
};
contentXML = new XML();
contentXML.ignoreWhite = true;
contentXML.onLoad = function() {
//now give the data to the tree
tree.dataProvider = this;
//format CDATA code nodes - remove extraneous newlines...
formatCodeNodes(this.firstChild);
//get keywords off the BIN icon
keywords.clear();
for (var i in this.firstChild.lastChild.attributes){
if (i != 'name'){
keywords.addWord(i, this.firstChild.lastChild.attributes[i]);
}
}
tree.selectedNode = tree.getTreeNodeAt(0);
//show the properties...
var atts = tree.selectedItem.attributes;
//refresh them first...
accord.propPane.propEdit.removeAll();
for (var i in atts) {
var obj = {Property:i, Value:atts[i]};
accord.propPane.propEdit.addItem(obj);
}
//make the combobox
makeComboMenu(tree.selectedItem.nodeName, tree.selectedItem.attributes.type);
//check for a bin and make one...
if (this.fileName.indexOf('.rlm') == -1){
if (contentXML.firstChild.lastChild.nodeName != 'BIN') {
var tempNode = new XML('');
contentXML.firstChild.appendChild(tempNode.firstChild);
}
tree.setIsOpen(tree.getTreeNodeAt(0), true);
//find the interface icon to open
var lo = tree.getTreeNodeAt(0);
for (var i = 0; i < lo.childNodes.length; i++){
if (lo.childNodes[i].nodeName == 'IFC'){
tree.setIsOpen(lo.childNodes[i], true);
}
}
} else {
tree.setIsOpen(tree.getTreeNodeAt(0), true);
}
if (this.fileName.indexOf('.rla') != -1){
playApplication();
}
if (this.fileName.indexOf('.rlt') != -1){
var userMode = mdm.System.Registry.loadString(2, "Software\\UoN\\Xerte", "userMode");
if (userMode != "developer"){
mdm.Forms.MainForm.hide();
}
runKOWizard();
}
};
function formatCodeNodes(element) {
//remove newlines from the script CDATA sections...
if (element.nodeType == 3) {
element.nodeValue = replace(element.nodeValue, newline, '');
}
if (element.attributes.bookmark) {
delete element.attributes.bookmark;
}
for (var i = 0; i';
} else if (fileList[i].indexOf('.swf') != -1 || fileList[i].indexOf('.png') != -1 || fileList[i].indexOf('.jpg') != -1){
libXMLStr += '';
}
}
libXMLStr += '';
//save the XML
mdm.FileSystem.saveFile(launchPath+'swfmill\\lib.xml', libXMLStr);
//call swfmill - write a batch file and call it
batStr = 'cd %~dp0\n\rswfmill.exe simple "' + mdm.Application.path + 'swfmill\\lib.xml" "' + editor.contentXML.fileName.substr(0, editor.contentXML.fileName.lastIndexOf("\\") + 1) + 'resources.swf"';
mdm.FileSystem.saveFile(mdm.Application.path+'swfmill\\compile.bat', batStr);
mdm.System.execStdOut(mdm.Application.path + 'swfmill\\compile.bat');
var r = mdm.Dialogs.promptAdv("The library resources.swf has compiled. You should restart Xerte.", "info");
}
if (obj.menuItem.attributes.label == "Publish") {
publish();
}
if (obj.menuItem.attributes.label == "SCORM 1.2") {
if (editor.filesFolder != ""){
mdm.browsefiledir(editor.filesFolder);
} else {
mdm.browsefiledir(mdm_desktop);
}
mdm.browsefiletitle('Create Content Package...');
mdm.browsefile_buttontext('Save');
mdm.browsefile_filterlist('Zip files|*.zip');
fscommand("mdm.browseFile", "events.packageFile");
}
if (obj.menuItem.attributes.label == "SCORM 2004") {
mdm.Dialogs.BrowseFile.dialogText = "Create Content Package...";
mdm.Dialogs.BrowseFile.buttonText = "Save";
mdm.Dialogs.BrowseFile.defaultDirectory = mdm.System.Paths.desktop;
mdm.Dialogs.BrowseFile.filterList = "ZIP Files|*.zip";
mdm.Dialogs.BrowseFile.title = "Save package as...";
var packageFile = mdm.Dialogs.BrowseFile.show();
if (packageFile.indexOf('.zip') == -1) packageFile += '.zip';
//get the location of the rlo .file
var fileLoc = editor.FileLocation.substr(0, editor.FileLocation.lastIndexOf('\\')+1);
//copy runtime files: XMLEngine, MainPreloader, scorm2004RLO.htm, flash.js, APIWrapper.js to fileLocation
mdm.copyfile(launchPath+'publish\\common\\MainPreloader.swf', fileLoc+'MainPreloader.swf');
mdm.copyfile(launchPath+'publish\\common\\XMLEngine.swf', fileLoc+'XMLEngine.swf');
if (!mdm.FileSystem.fileExists(fileLoc+'resources.swf')){
mdm.copyfile(launchPath+'publish\\common\\resources.swf', fileLoc+'resources.swf');
}
mdm.copyfile(launchPath+'publish\\scorm2004\\flash.js', fileLoc+'flash.js');
mdm.copyfile(launchPath+'publish\\scorm2004\\apiwrapper.js', fileLoc+'apiwrapper.js');
//make the hosting web page based on scorm2004RLO.htm
var fileName = editor.FileLocation.substr(editor.FileLocation.lastIndexOf('\\')+1, editor.FileLocation.length);
var SCOLoaderHTML = mdm.FileSystem.loadFile(launchPath+'publish\\scorm2004\\scorm2004RLO.htm');
var finalHTML = replace(SCOLoaderHTML, "%FILE%", fileName);
//if stage coords are set,
if (contentXML.firstChild.attributes.stageSize != undefined){
var stageCoords = contentXML.firstChild.attributes.stageSize.split(',');
finalHTML = replace(finalHTML, '%WIDTH%', stageCoords[0]);
finalHTML = replace(finalHTML, '%HEIGHT%', stageCoords[1]);
} else { //use the default
finalHTML = replace(finalHTML, '%WIDTH%', '800');
finalHTML = replace(finalHTML, '%HEIGHT%', '600');
}
var htmlFileName = 'scorm2004RLO.htm';
if (Key.isDown(Key.CONTROL)){
htmlFileName = mdm.Dialogs.inputBox("HTML File Name", "Enter the HTML File Name Here:");
}
if (htmlFileName.indexOf('.htm') == -1) htmlFileName += '.htm';
//write the file
mdm.FileSystem.saveFile(fileLoc+htmlFileName, finalHTML);
//make IDs for the manifest
var strID = String(new Date().getTime());
var orgID = "XERTE-ORG-"+strID;
var itemID = "XERTE-ITEM-"+strID;
var resID = "XERTE-RES-"+strID;
var Scorm2004Choice = "false";
var Scorm2004Flow = "true";
//write the manifest imsmanifest.xml
var manifestStr = '\r';
manifestStr += '\r';
manifestStr += 'ADL SCORMCAM 1.3\r';
manifestStr += '\r';
manifestStr += '\r';
manifestStr += '' + contentXML.firstChild.getChildByNodeName('IFC').attributes.name + '\r';
manifestStr += '- \r';
manifestStr += '' + contentXML.firstChild.getChildByNodeName('IFC').attributes.title + '\r';
manifestStr += ' \r';
manifestStr += '
\r';
if (contentXML.firstChild.getChildByNodeName('IFC').attributes.scorm2004Choice == "true")
Scorm2004Choice = "true";
if (contentXML.firstChild.getChildByNodeName('IFC').attributes.scorm2004Flow == "false")
Scorm2004Flow = "false";
manifestStr += ' \r';
manifestStr += '\r';
manifestStr += '\r';
manifestStr += '\r';
manifestStr += '\r';
mdm.FileSystem.saveFile(fileLoc+'imsmanifest.xml', manifestStr);
//copy the schema files - unzip the 2004schema.zip file in the project folder
var fsparams = '"'+launchPath+'publish\\scorm2004\\2004schema.zip'+"\",\""+fileLoc+"\",\"none\"";
fscommand("flashvnn.ExtractZip", fsparams);
//and then zip the folder
var destZip = packageFile;
var sourceFolder = editor.FileLocation.substr(0, editor.FileLocation.lastIndexOf('\\')+1);
var fsparams = '"'+packageFile+"\",\""+sourceFolder+"\",\"*.*\",\"none\"";
fscommand("flashvnn.ZipFolder", fsparams);
fscommand("flashvnn.CloseZip", "");
mdm.prompt("Packaging complete. SCORM 2004 compliant package created.");
}
if (obj.menuItem.attributes.label == "Installer...") {
//find the .rla file
mdm.Dialogs.BrowseFile.dialogText = "Select an Application File...";
mdm.Dialogs.BrowseFile.buttonText = "Select";
mdm.Dialogs.BrowseFile.defaultDirectory = mdm.System.Paths.desktop;
mdm.Dialogs.BrowseFile.filterList = "Learning Applications|*.rla|HTM Files|*.htm|HTML Files|*.html";
mdm.Dialogs.BrowseFile.title = "Select the launching file";
mdm.Dialogs.BrowseFile.defaultExtension = "rla";
var inputFile = mdm.Dialogs.BrowseFile.show();
if (inputFile != 'false'){
//get vars for writing the iss file
var inputFolder = inputFile.substr(0, inputFile.lastIndexOf('\\') + 1);
var appName = inputFile.substring(inputFile.lastIndexOf('\\') + 1, inputFile.lastIndexOf('.'))
var appFile = inputFile.substr(inputFile.lastIndexOf('\\') + 1);
//get an output folder...
var outputFolder = inputFolder + "installer\\";
//read in the simple.iss file...
var issFile = mdm.FileSystem.loadFile(mdm.Application.path + "inno\\simple.iss");
//replace the tokens with vars
issFile = replace(issFile, '%INPUTDIR%', inputFolder + '*.*');
issFile = replace(issFile, '%APPNAME%', appName);
issFile = replace(issFile, '%APPFILE%', appFile);
issFile = replace(issFile, '%OUTPUTDIR%', outputFolder);
//write the file
mdm.FileSystem.saveFile(inputFolder + 'setup.iss', issFile);
//delete the setup.exe file if it exists
if (mdm.FileSystem.fileExists(outputFolder + "setup.exe")){
mdm.FileSystem.deleteFile(outputFolder + "setup.exe");
}
//call the compiler
mdm.System.execStdOut(mdm.Application.path + 'inno\\iscc /Q "' + inputFolder + 'setup.iss"');
}
}
if (obj.menuItem.attributes.label == "Exit") {
if (editor.FileLocation != ""){
var result = mdm.Dialogs.PromptModal("Do you want to exit Xerte?", "yesno", "confirm");
if (result == true){
var fileSave = mdm.Dialogs.PromptModal("Save file before exit?", "yesno", "confirm");
if (fileSave == true){
saveFile();
}
mdm.Application.exit();
}
} else {
mdm.Application.exit();
}
}
};
fileMenu.addEventListener("change", fileMenuListener);
function publish(){
//create the html launcher page
var fileLoc = editor.FileLocation.substr(0, editor.FileLocation.lastIndexOf('\\')+1);
//runtime files
mdm.copyfile(launchPath+'publish\\common\\MainPreloader.swf', fileLoc+'MainPreloader.swf');
mdm.copyfile(launchPath+'publish\\common\\XMLEngine.swf', fileLoc+'XMLEngine.swf');
if (!mdm.FileSystem.fileExists(fileLoc+'resources.swf')){
mdm.copyfile(launchPath+'publish\\common\\resources.swf', fileLoc+'resources.swf');
}
mdm.copyfile(launchPath+'publish\\html\\rloObject.js', fileLoc+'rloObject.js');
//create HTML based on loader.html
var fileName = editor.FileLocation.substr(editor.FileLocation.lastIndexOf('\\')+1);
var LoaderHTML = mdm.FileSystem.loadFile(launchPath+'publish\\html\\rloObject.html');
var finalHTML = replace(LoaderHTML, '%FILE%', fileName);
//if stage coords are set,
if (contentXML.firstChild.attributes.stageSize != undefined){
var stageCoords = contentXML.firstChild.attributes.stageSize.split(',');
finalHTML = replace(finalHTML, '%WIDTH%', stageCoords[0]);
finalHTML = replace(finalHTML, '%HEIGHT%', stageCoords[1]);
} else { //use the default
finalHTML = replace(finalHTML, '%WIDTH%', '800');
finalHTML = replace(finalHTML, '%HEIGHT%', '600');
}
finalHTML = replace(finalHTML, 'Interactive Learning Content', contentXML.firstChild.getChildByNodeName('IFC').attributes.title);
var htmlFileName = 'index.htm';
if (Key.isDown(Key.CONTROL)){
htmlFileName = mdm.Dialogs.inputBox("HTML File Name", "Enter the HTML File Name Here:");
}
if (htmlFileName.indexOf('.htm') == -1) htmlFileName += '.htm';
mdm.FileSystem.saveFile(fileLoc+htmlFileName, finalHTML);
mdm.prompt("Publish complete. All files for web deployment created.");
}
function packageSCO(fileName){
events.packageFile = fileName;
}
editMenu = menuBar.addMenu("Edit");
//editMenu.addMenuItem({label:"Undo", icon:'icUndo'});
//editMenu.addMenuItem({type:"separator"});
editMenu.addMenuItem({label:"Cut Icon", icon:'icCut'});
editMenu.addMenuItem({label:"Copy Icon",icon:'icCopy'});
editMenu.addMenuItem({label:"Paste Icon",icon:'icPaste'});
editMenu.addMenuItem({label:"Duplicate Icon",icon:'icDuplicate'});
editMenu.addMenuItem({type:"separator"});
editMenu.addMenuItem({label:"Variables...",icon:'icVars'});
/*
editMenu.addMenuItem({type:"separator"});
editMenu.addMenuItem({label:"Options...",icon:'icOptions'});
*/
editMenuListener = new Object();
editMenuListener.change = function(obj) {
if (obj.menuItem.attributes.label == "Undo") {
if (undoManager.undoStack.length != 0){
}
}
if (obj.menuItem.attributes.label == "Cut Icon") {
cutIcon();
}
if (obj.menuItem.attributes.label == "Copy Icon") {
copyIcon();
}
if (obj.menuItem.attributes.label == "Paste Icon") {
pasteIcon();
}
if (obj.menuItem.attributes.label == "Duplicate Icon") {
duplicateNode();
}
if (obj.menuItem.attributes.label == "Variables...") {
editVars()
}
}
editMenu.addEventListener("change", editMenuListener);
cutIcon = function(){
var parent = tree.selectedItem.parentNode;
editor.clipboardNode = tree.selectedItem.cloneNode(true);
tree.selectedItem.removeNode();
tree.selectedNode = parent;
tree.dataProvider = tree.dataProvider;
tree.dispatchEvent({type:'change', target:tree});
}
copyIcon = function(){
editor.clipboardNode = tree.selectedItem.cloneNode(true);
}
pasteIcon = function(){
var tempNode = editor.clipboardNode.cloneNode(true);
//paste into the currently selected icon (like insert)
var parent = tree.selectedNode;
parent.appendChild(editor.clipboardNode);
tree.setIsOpen(parent, true);
tree.dataProvider = tree.dataProvider;
tree.dispatchEvent({type:'change', target:tree});
mdm.setwindowtitle('XERTE '+ contentXML.fileName + '*');
editor.clipboardNode = tempNode;
}
editVars = function(){
userVars._x = 200;
userVars._y = 100;
userVars._visible = true;
userVars.init(contentXML.firstChild.lastChild.attributes);
}
viewMenu = menuBar.addMenu("View");
viewMenu.addMenuItem({label:"Expand All",icon:'icExpandAll'});
viewMenu.addMenuItem({label:"Collapse All",icon:'icCollapseAll'});
viewMenu.addMenuItem({type:"separator"});
viewMenu.addMenuItem({label:"Icon Palette",icon:'icOptions'});
viewMenu.addMenuItem({type:"separator"});
viewMenu.addMenuItem({label:"Preview",icon:'icPreview'});
viewMenuListener = new Object();
viewMenuListener.change = function(obj) {
if (obj.menuItem.attributes.label == "Expand All") {
expandAll(tree.getNodeDisplayedAt(0));
}
if (obj.menuItem.attributes.label == "Collapse All") {
collapseAll(tree.getNodeDisplayedAt(0));
}
if (obj.menuItem.attributes.label == "Icon Palette") {
if (iconPalette._visible == true){
iconPalette._visible = false;
} else {
iconPalette._visible = true;
}
}
if (obj.menuItem.attributes.label == "Preview") {
if (editor.FileLocation != "" && contentXML.fileName.indexOf('.rlm') == -1){
F5Listener.mode = 'preview';
mdm.form_show("preview");
mdm.form_restore("preview");
saveFile();
mdm.form_callfunction("preview", "setMode", mode, "|");
mdm.form_callfunction("preview", "jumpFile", editor.FileLocation, "|");
}
}
}
viewMenu.addEventListener("change", viewMenuListener);
templatesMenu = menuBar.addMenu("Templates");
templatesMenuListener = {};
templatesMenuListener.change = function(obj) {
if (obj.menuItem.attributes.label == 'Create Template'){
createTemplatePackage();
return;
}
if (obj.menuItem.attributes.label == 'Install Template'){
installTemplatePackage();
return;
}
//handle wizards and tempaltes selected
if (obj.menuItem.attributes.data.indexOf('.xtp') != -1)
{
makeTemplateProject(mdm.Application.path + 'wizards\\' + obj.menuItem.attributes.data);
}
else if (obj.menuItem.attributes.data.indexOf('.xcp') != -1)
{
insertPageTemplate(mdm.Application.path + 'wizards\\' + obj.menuItem.attributes.data)
}
}
templatesMenu.addEventListener("change", templatesMenuListener);
function addTemplatesToMenu(){
//installer....
templatesMenu.addMenuItem({label: 'Create Template', icon:'icCreatetemplate'});
templatesMenu.addMenuItem({label: 'Install Template', icon:'icInstallTemplate'});
templatesMenu.addMenuItem({type:"separator"});
var files = mdm.FileSystem.getFileList(mdm.Application.path + 'wizards\\', "*.xtp");
files.sort();
for (var i = 0; i < files.length; i++){
templatesMenu.addMenuItem({label: files[i].substr(0, files[i].indexOf('.')), data:files[i], icon:'icTemplate'});
}
//.xcp files
templatesMenu.addMenuItem({type:"separator"});
files = mdm.FileSystem.getFileList(mdm.Application.path + 'wizards\\', "*.xcp");
files.sort();
for (var i = 0; i < files.length; i++){
templatesMenu.addMenuItem({label: files[i].substr(0, files[i].indexOf('.')), data:files[i], icon:'icTemplate'});
}
//folders
var folders = mdm.FileSystem.getFolderList(mdm.Application.path + 'wizards\\');
for ( var i = 0; i < folders.length; i++){
//add a top level menu
var temp = templatesMenu.addMenuItem({label:folders[i], icon:'icTools'});
files = mdm.FileSystem.getFileList(mdm.Application.path + 'wizards\\' + folders[i] + '\\', "*.xcp");
files.sort();
for (var j = 0; j < files.length; j++){
temp.addMenuItem({label: files[j].substr(0, files[j].indexOf('.')), data:folders[i] + '\\' + files[j], icon:'icTemplate'});
}
}
}
addTemplatesToMenu();
function resizePreview(){
//called by glo editor
if (contentXML.firstChild.attributes.stageSize != undefined){
var w = Number(contentXML.firstChild.attributes.stageSize.split(',')[0]);
var h = Number(contentXML.firstChild.attributes.stageSize.split(',')[1]);
} else {
var w = 800;
var h = 600;
}
mdm.Forms.preview.width = w + widthError;
mdm.Forms.preview.height = h + heightError;
}
function expandAll(node){
if (node.nodeName != 'DIS' && node.nodeName != 'SCR' && node.nodeName != 'BIN'){
tree.setIsOpen(node, true);
}
for (var i =0 ; i < node.childNodes.length; i++){
expandAll(node.childNodes[i]);
}
}
function collapseAll(node){
if (node.nodeName != 'LO' && node.nodeName != 'IFC'){
tree.setIsOpen(node, false);
}
for (var i =0 ; i < node.childNodes.length; i++){
collapseAll(node.childNodes[i]);
}
}
//F5 for preview...
F5Listener = new Object();
F5Listener.mode = 'edit';
F5Listener.onKeyDown = function() {
if (Key.isDown(116) && editor.FileLocation != "" && contentXML.fileName.indexOf('.rlm') == -1){ //F5 pressed
if (this.mode == 'edit') {
//edit mode
this.mode = 'preview';
//prevent the properties panel having an open edit
if (Key.isDown(Key.CONTROL)) {
//find the page / fw that the current icon belongs to for fast navigation in preview mode
if (F5Listener.currentNode != undefined) {
delete this.currentNode.attributes.bookmark;
}
this.currentNode = tree.selectedItem;
while (this.currentNode.parentNode != undefined) {
if (this.currentNode.nodeName == 'PG' && (this.currentNode.parentNode.nodeName == 'FW' || this.currentNode.parentNode.nodeName == 'IFC')) {
this.currentNode.attributes.bookmark = 'bookmark';
break;
}
this.currentNode = this.currentNode.parentNode;
}
}
//if shift is down, allow the icon to be moved and resized - there is a bug in navigate
if (Key.isDown(Key.SHIFT)){
if (F5Listener.editNode != undefined) {
delete this.editNode.attributes.bookmark;
}
this.editNode = tree.selectedItem;
this.editNode.attributes.bookmark = "edit";
}
if (contentXML.firstChild.attributes.stageSize != undefined){
var w = Number(contentXML.firstChild.attributes.stageSize.split(',')[0]) + widthError;
var h = Number(contentXML.firstChild.attributes.stageSize.split(',')[1]) + heightError;
} else {
var w = 800 + widthError;
var h = 600 + heightError;
}
mdm.Forms.preview.width = w;
mdm.Forms.preview.height = h;
mdm.form_show("preview");
mdm.form_restore("preview");
saveFile();
delete tree.selectedNode.attributes.bookmark;
if (Key.isDown(Key.CONTROL)) {
var mode = "navigate";
} else {
var mode = "fromtop";
}
mdm.form_callfunction("preview", "setMode", mode, "|");
mdm.form_callfunction("preview", "jumpFile", editor.FileLocation, "|");
} else {
//preview mode...
this.mode = 'edit';
mdm.form_hide("preview");
//update any changed attributes
tree.dispatchEvent({target:tree, type:'change'});
}
}
//help key
if (Key.isDown(112)){
_level0.helpURL = _level0.mdm_appdir+"help\\Xerte.chm";
fscommand("mdm.exec", "_level0.helpURL");
}
//ctrl-s to save
if (Key.isDown(Key.CONTROL) && Key.isDown(83)){
if (contentXML.fileName) {
saveFile();
} else {
mdm.prompt("There is no file to save.");
}
}
//ctrl-n for new file
if (Key.isDown(Key.CONTROL) && Key.isDown(78)){
events.action = "New";
mdm.browsefiledir(mdm_desktop);
mdm.browsefiletitle('Save New File As...');
mdm.browsefile_buttontext('Save');
mdm.browsefile_filterlist('Learning Objects|*.rlo|MXML Files|*.mxml');
fscommand("mdm.browseFile", "events.newFileName");
}
//ctrl o for open file
if (Key.isDown(Key.CONTROL) && Key.isDown(79)){
if (editor.filesFolder != ""){
mdm.browsefiledir(editor.filesFolder);
} else {
mdm.browsefiledir(mdm_desktop);
}
mdm.browsefiletitle('Open File...');
mdm.browsefile_buttontext('Open');
mdm.browsefile_filterlist('Learning Objects|*.rlo|MXML Files|*.mxml');
fscommand("mdm.browseFile", "events.fileName");
}
//ctrl-m for import media
if (Key.isDown(Key.CONTROL) && Key.isDown(77)){
if (tree.selectedItem.nodeName == 'PG' || tree.selectedItem.nodeName == 'FW_ENT' || tree.selectedItem.nodeName == 'RES'){
//open browse dialog for swf, jpg, mp3 and txt
mdm.Dialogs.BrowseFile.dialogText = "Import Media...";
mdm.Dialogs.BrowseFile.buttonText = "Select";
mdm.Dialogs.BrowseFile.defaultDirectory = mdm.System.Paths.desktop;
mdm.Dialogs.BrowseFile.filterList = "Images|*.jpg|Flash|*.swf|Sounds|*.mp3|Text|*.txt";
mdm.Dialogs.BrowseFile.title = "Select the file to import";
mdm.Dialogs.BrowseFile.defaultExtension = "jpg";
var inputFile = mdm.Dialogs.BrowseFile.show();
if (inputFile != 'false'){
getFileName(inputFile);
}
} else {
mdm.Dialogs.promptAdv("You must select a page icon to import media.", "info")
}
}
if (Key.isDown(Key.DELETEKEY) && Selection.getFocus() == "_level0.dndtree.tree"){
deleteNode();
}
};
Key.addListener(F5Listener);
updateXYAttributes = function(x,y){
//update the selected icon's x and y values
//all editable icons can be moved
tree.selectedNode.attributes.x = Math.floor(x);
tree.selectedNode.attributes.y = Math.floor(y);
delete tree.selectedNode.attributes.bookmark;
tree.dispatchEvent({target:tree, type:'change'});
}
updateWHAttributes = function(w,h){
//update the selected icon's w and h values - not al editable icons can be resized...
//can resize DIS text, DIS ext, RES hs, RES button, RES label
var name = tree.selectedNode.nodeName;
var type = tree.selectedNode.attributes.type;
//cannot change dims on movies
if (name != 'MOV'){
tree.selectedNode.attributes.w = w;
//cannot change h on rads, chks, cbos,
if (type != 'radio' && type != 'checkBox' && type != 'combo'){
tree.selectedNode.attributes.h = h;
}
delete tree.selectedNode.attributes.bookmark;
tree.dispatchEvent({target:tree, type:'change'});
}
}
selectByIndices = function(indices){
var myArray = indices.split(',');
var currentNode = contentXML.firstChild;
for (var i = myArray.length - 2; i >= 0; i--){
currentNode = currentNode.childNodes[Number(myArray[i])];
}
//open all parent nodes...
if (tree.getIsOpen(currentNode)) tree.setIsOpen(currentNode, true);
var tempNode = currentNode.parentNode;
while (tempNode.parentNode != undefined){
tree.setIsOpen(tempNode, true);
tempNode = tempNode.parentNode;
}
tree.selectedNode = currentNode;
tree.dispatchEvent({type:"change", target:tree});
}
undoListener = new Object();
undoListener.onKeyDown = function(){
if (Key.isDown(90) && Key.isDown(Key.CONTROL)){
undo();
}
}
Key.addListener(undoListener);
function playApplication(){
Key.removeListener(F5Listener);
menuBar.enabled = false;
tree.enabled = false;
accord.enabled = false;
mdm.setwindowtitle(contentXML.firstChild.firstChild.attributes.title);
//load up the engine and load the application above the editor...
this.createEmptyMovieClip('appPlayer', 99);
this.appPlayer.loadMovie(mdm.Application.path + 'XMLEngine.swf', 0);
}
function launchWizard(){
Key.removeListener(F5Listener);
menuBar.enabled = false;
tree.enabled = false;
accord.enabled = false;
mdm.setwindowtitle(contentXML.firstChild.firstChild.attributes.title);
//load up the engine and load the application above the editor...
this.createEmptyMovieClip('appPlayer', 99);
this.appPlayer.loadMovie(mdm.Application.path + 'XMLEngine.swf', 0);
}
function setMode(){
//called by the preview form to set the mode and hide the preview form
F5Listener.mode = 'edit';
mdm.form_hide("preview");
}
//do commands menu
commands = new XML();
commands.ignoreWhite = true;
commands.load('tools.xml');
commands.onLoad = function() {
commandsMenu = menuBar.addMenu('Tools', this);
//set up the listener...
commandsMenuListener = new Object();
commandsMenuListener.change = function(obj) {
cmdWin = PopUpManager.createPopUp(editor, mx.containers.Window, false);
cmdWin.setSize(500, 300);
cmdWin._x = 150;
cmdWin._y = 150;
cmdWin.closeButton = true;
cmdWin.title = obj.menuItem.attributes.label;
cmdWin.contentPath = 'tools/'+obj.menuItem.attributes.data;
cmdWinListener = new Object();
cmdWinListener.click = function(evt) {
editor.cmdWin.deletePopUp();
};
cmdWin.addEventListener("click", cmdWinListener);
};
commandsMenu.addEventListener("change", commandsMenuListener);
/*
templatesMenu = menuBar.addMenu('Templates');
//templatesMenu.addMenuItem({type:"separator"});
templatesMenu.addMenuItem({label: 'Templates...', icon:'icDesignPatterns'});
templatesMenuListener = new Object();
templatesMenuListener.change = function(obj) {
if (obj.menuItem.attributes.label == "New Template Project...") {
newTemplateProject();
}
if (obj.menuItem.attributes.label == "Create Template Package...") {
createTemplatePackage();
}
if (obj.menuItem.attributes.label == "Create Page Template...") {
createPageTemplate();
}
if (obj.menuItem.attributes.label == "Templates...") {
mdm.Forms.wizard.callFunction("init", mdm.Application.path + "patterns\\patterns.xml|"+editor.FileLocation+"|true", "|");
}
};
templatesMenu.addEventListener("change", templatesMenuListener);
*/
//now set up other menus...
helpMenu = menuBar.addMenu('Help');
helpMenu.addMenuItem({label:"Help...", icon:'icHelp'});
helpMenu.addMenuItem({label:"ActionScript...", icon:'icHelp'});
helpMenu.addMenuItem({type:"separator"});
helpMenu.addMenuItem({label:"Tips...", icon:'icTips'});
//helpMenu.addMenuItem({label:"ActionScript..."});
helpMenu.addMenuItem({type:"separator"});
helpMenu.addMenuItem({label:"About...",icon:'icAbout'});
helpMenuListener = new Object();
helpMenuListener.change = function(obj) {
if (obj.menuItem.attributes.label == "Help...") {
//launch help page...
_level0.helpURL = _level0.mdm_appdir+"help\\Xerte.chm";
fscommand("mdm.exec", "_level0.helpURL");
}
if (obj.menuItem.attributes.label == "ActionScript...") {
//launch help page...
mdm.Network.getURL("http://help.adobe.com/en_US/AS2LCR/Flash_10.0/help.html?content=Part2_AS2_LangRef_1.html");
}
if (obj.menuItem.attributes.label == "Tips...") {
//launch tips
var tipsResult = mdm.Application.showTips(tipsString);
if (tipsResult == false) {
//turn off tips
mdm.System.Registry.saveString(2, "Software\\UoN\\Xerte", "tips", "0");
} else {
//turn them back on
mdm.System.Registry.saveString(2, "Software\\UoN\\Xerte", "tips", "1");
}
}
if (obj.menuItem.attributes.label == "ActionScript Reference...") {
//launch help page...
//_level0.helpURL = _level0.mdm_appdir+"help\\actionscript.chm";
//fscommand("mdm.exec", "_level0.helpURL");
}
if (obj.menuItem.attributes.label == "About...") {
editor.attachMovie('aboutBox', 'aboutBox', 99, {_x: 330, _y: 180});
editor.aboutBox.onRelease = function(){
this.removeMovieClip();
}
}
};
helpMenu.addEventListener("change", helpMenuListener);
};
//set up accordian component//////////////////////////////////////////////////////////
accord.setStyle("backgroundColor", 0x666666);
accord.createChild("View", "propPane", {label:"Properties", icon: "icDisOpen"});
accord.createChild("View", "textPane", {label:"Text", icon: "icDisClosed"});
accord.createChild("View", "codePane", {label:"Script", icon: "icDisClosed"});
accord.currentFrame = 0; //keeps track of currently opened frame
accord.codePane.onKeyDown = function(){
if (Selection.getFocus() == "_level0.accord.codePane.codeEdit.label"){
var doInit = !snippets._visible;
clearInterval(snippets.intID);
if (Key.isDown(Key.CONTROL) && Key.isDown(Key.SHIFT)) snippets._visible = !snippets._visible;
if (snippets._visible == true && doInit){
snippets.init(Selection.getBeginIndex(), Selection.getEndIndex());
}
if (Key.isDown(Key.ENTER)){
//add as many spaces before the caret as there were on the previous line
var str = this.codeEdit.label.text;
var index = Selection.getBeginIndex();
var lastNewLine = str.lastIndexOf('\r', index - 1) + 1;
var line = str.substr(lastNewLine, index - lastNewLine);
var pre = str.substr(0, index);
var end = str.substr(index);
var indent = '';
//friendly comments...
if (line.substr(0,2) == '* ' || line.substr(0,2) == '/*'){
if (!Key.isDown(Key.SHIFT)){
this.codeEdit.label.replaceText(index,index, '* ');
} else {
this.codeEdit.label.replaceText(index,index, '*/');
}
selID = setInterval(doSel, 0, index + 3);
return;
}
for (var i = 0 ; i < line.length; i++){
if (line.substr(i,1) == ' '){
indent += ' ';
} else {
break;
}
}
if (indent.length > 0){
this.codeEdit.label.replaceText(index,index, indent);
selID = setInterval(doSel, 0, index + indent.length + 1);
}
}
}
}
function doSel(index){
clearInterval(selID);
Selection.setSelection(index, index);
}
Key.addListener(accord.codePane);
snippets._visible = false;
undoManager = new Object();
undoManager.undoStack = new Array();
undoManager.currentObject = "";
//add the child controls to each pane/////////////////////////////////////////////////
//dummy white MC
accord.propPane.createChild("dummyMC", "dummyMC");
var obj = accord.propPane.createChild("ComboBox", "optProps");
obj._x = 5;
obj._y = 5;
obj.setSize(200, 20);
obj.editable = true;
var obj = accord.propPane.createChild("Button", "addProp");
obj.label = 'Add';
obj._x = 210;
obj._y = 5;
obj.setSize(40, 20);
obj.enabled = false;
var obj = accord.propPane.createChild("Button", "delProp");
obj.label = 'Delete';
obj._x = 255;
obj._y = 5;
obj.setSize(60, 20);
obj.enabled = false;
var obj = accord.propPane.createChild("DataGrid", "propEdit");
var cp = accord.propPane.createChild("AdvColorPicker", "colPick");
obj.setSize(680, 604);
obj._x -= 1;
obj._y = 30;
//styles for the datagrid...
obj.sortableColumns = true;
obj.setStyle("alternatingRowColors", [0xFFFFFF, 0xF9F9F9]);
obj.iconFunction = function(item){
return 'icFW';
};
//done styles - add columns
obj.addColumn('Property');
obj.getColumnAt(0).width = 210;
//obj.getColumnAt(0).fontWeight = "bold";
obj.addColumn('Value');
obj.getColumnAt(1).width = 460;
obj.editable = true;
var names = obj.getColumnAt(0);
names.editable = false;
//set up a context menu for the data grid to allow errant props to be deleted...
function delProp() {
if (tree.selectedNode.nodeName == 'BIN'){
keywords.userDefined[accord.propPane.propEdit.getItemAt(accord.propPane.propEdit.selectedIndex).Property];
}
//delete the attribute
delete tree.selectedItem.attributes[accord.propPane.propEdit.getItemAt(accord.propPane.propEdit.selectedIndex).Property];
//refresh the list...
accord.propPane.propEdit.removeAll();
//show all attributes as properties...
var atts = tree.selectedItem.attributes;
for (var i in atts) {
var obj = {Property:i, Value:atts[i]};
if (obj.Property != 'type') {
accord.propPane.propEdit.addItem(obj);
}
}
}
//set up the colour picker
cp._x = 320;
cp._y = 7;
cp.columns = 21;
cp.useAdvancedColorSelector = true;
cpList = new Object();
cpList.change = function(obj){
System.setClipboard(obj.getRGB());
}
cp.addListener(cpList);
var propMenu = new ContextMenu(getRightMouseClick);
function getRightMouseClick() {
accord.propPane.propEdit.selectedIndex = accord.propPane.propEdit.rolledOverIndex;
accord.propPane.propEdit.dispatchEvent({type:"change", target:accord.propPane.propEdit});
}
propMenu.hideBuiltInItems();
//propMenu.customItems.push(new ContextMenuItem("Delete Property...", delProp));
accord.menu = propMenu;
obj = accord.textPane.createChild("TextArea", "textEdit");
obj.setStyle('fontFamily', 'Verdana');
obj.setSize(680, 634);
obj.wordWrap = true;
obj = accord.codePane.createChild("TextArea", "codeEdit");
obj.setStyle('fontFamily', 'Courier New');
obj.setSize(680, 634);
obj.label.prevLength = 0;
//LISTENERS//////////////////////////////////////////////////////////////////////////////
//tree changes
treeListener = new Object();
treeListener.lastClickTime = getTimer();
treeListener.change = function(tree) {
if (Key.isDown(Key.SHIFT)){
var SHIFT_DOWN = true;
} else {
var SHIFT_DOWN = false;
}
//refresh the icon palette to show only valid icons
iconPalette.iconsTree.getTree().refresh();
if (getTimer() - this.lastClickTime < 350) {
//expand the branch?
if ((tree.target.selectedNode.firstChild.nodeType != '3' && tree.target.selectedNode.attributes.templateData == undefined) || SHIFT_DOWN == true) {
if (SHIFT_DOWN == true && tree.target.selectedNode.attributes.templateData == undefined){
if (tree.target.getIsOpen(tree.target.selectedNode)){
collapseAll(tree.target.selectedNode);
} else {
expandAll(tree.target.selectedNode);
}
} else {
tree.target.setIsOpen(tree.target.selectedNode, !tree.target.getIsOpen(tree.target.selectedNode));
}
}
//fire up the KO wizard if a KO selected and shift is not down
if (tree.target.selectedNode.attributes.templateData != undefined && SHIFT_DOWN == false){
saveFile();
runKOWizard();
}
//fire up the KO wizard if a KO selected and shift is not down
if (tree.target.selectedNode.nodeName == 'DRW'){
mdm.Forms.drawing.show();
mdm.Forms.drawing.callFunction("init", tree.target.selectedItem.firstChild.nodeValue+"|"+editor.FileLocation+"|", "|");
}
if (tree.target.selectedNode.attributes.model != undefined){
//open another instance of the editor, with the path on the command line...
var modelToEdit = tree.target.selectedItem.attributes.model;
if (modelToEdit.indexOf('FileLocation') != -1){
modelToEdit = replace(modelToEdit, 'FileLocation + ', editor.FileLocation.substr(0, editor.FileLocation.lastIndexOf('\\')+1));
}
if (modelToEdit.indexOf('templatePath') != -1){
modelToEdit = replace(modelToEdit, 'templatePath + ', editor.FileLocation.substr(0, editor.FileLocation.lastIndexOf('\\')+1));
}
modelToEdit = replace(modelToEdit, "'", "");
mdm.System.exec(modelToEdit);
}
}
this.lastClickTime = getTimer();
//figure out which type of node
var nodeType = tree.target.selectedItem.nodeName;
//show appropriate items on context menu - call makeContextMenu(type)
//makeContextMenu(nodeType);
//add optional properties to the combobox
tree.target.rolledOverIndex = tree.target.selectedIndex;
makeComboMenu(nodeType, tree.target.selectedNode.attributes.type);
//refresh and display the existing properties on the data grid
accord.propPane.propEdit.removeAll();
accord.textPane.textEdit.text = "";
accord.codePane.codeEdit.text = "";
//show all attributes as properties...
if (tree.target.selectedNode.nodeName != 'BIN'){
var atts = tree.target.selectedItem.attributes;
for (var i in atts) {
var obj = {Property:i, Value:atts[i]};
if (obj.Property != 'type') {
accord.propPane.propEdit.addItem(obj);
}
}
}
accord.propPane.propEdit.selectedIndex = 0;
//do text on DIS tags...
if (tree.target.selectedItem.nodeName == 'DIS' || tree.target.selectedItem.nodeName == 'MOV' ) {
//create new undo stack
undoManager.undoStack = new Array();
undoManager.undoStack.push(tree.target.selectedItem.firstChild.nodeValue);
accord.textPane.textEdit.text = tree.target.selectedItem.firstChild.nodeValue;
accord.textPane.textEdit.redraw();
accord.textPane.textEdit.label.highlight(0, accord.textPane.textEdit.label.text.length);
}
//do code...
if (tree.target.selectedItem.nodeName == 'SCR') {
//create new undo stack
undoManager.undoStack = new Array();
undoManager.undoStack.push(tree.target.selectedItem.firstChild.nodeValue);
accord.codePane.codeEdit.text = tree.target.selectedItem.firstChild.nodeValue;
//nb first child
accord.codePane.codeEdit.redraw();
accord.codePane.codeEdit.label.prevLength = tree.target.selectedItem.firstChild.nodeValue.length;
accord.codePane.codeEdit.label.highlightAll();
}
//select the appropriate pane in the accordian
if (nodeType != 'SCR' && nodeType != 'DIS' && nodeType != 'MOV') {
accord.dispatchEvent({type:"change", target:accord, sender: 'tree', nodeType:'nonTxt'});
}
if (nodeType == 'SCR') {
accord.dispatchEvent({type:"change", target:accord, sender: 'tree', nodeType:'SCR'});
}
if (nodeType == 'DIS') {
accord.dispatchEvent({type:"change", target:accord, sender: 'tree',nodeType:'DIS'});
}
if (nodeType == 'MOV') {
accord.dispatchEvent({type:"change", target:accord, sender: 'tree',nodeType:'MOV'});
}
//ensure we reset the bookmark if set
if (F5Listener.currentNode != undefined) {
delete F5Listener.currentNode.attributes.bookmark;
}
//and the edit node
if (F5Listener.editNode != undefined) {
delete F5Listener.editNode.attributes.bookmark;
}
};
tree.addEventListener("change", treeListener);
treeListener.itemRollOver = function(obj) {
tree.rolledOverIndex = obj.index;
var nodeType = tree.getNodeDisplayedAt(obj.index).nodeName;
if (nodeType != undefined) {
makeContextMenu(nodeType);
}
};
tree.addEventListener("itemRollOver", treeListener);
//Accordian changes
accordListener = new Object();
accordListener.change = function(obj){
if (snippets._visible == true) snippets._visible = false;
////////////////////////////////////////////////////////////////////////////////
//automatically select appropriate pane when tree is the sender/////////////////
if (obj.sender == 'tree'){
accord.treeChange = 1;
if (accord.selectedIndex != -1){
if (obj.nodeType == 'DIS' || obj.nodeType == 'MOV'){
if (obj.target.selectedIndex == 2){
obj.target.selectedIndex = 1;
accord.currentFrame = 1;
} else if (obj.target.selectedIndex != 1){
obj.target.selectedIndex = 0;
accord.currentFrame = 0;
}
} else if (obj.nodeType == 'SCR'){
if (obj.target.selectedIndex == 1){
obj.target.selectedIndex = 2;
accord.currentFrame = 2;
} else if (obj.target.selectedIndex != 2){
obj.target.selectedIndex = 0;
accord.currentFrame = 0;
}
} else { //it is any other icon
obj.target.selectedIndex = 0;
accord.currentFrame = 0;
}
}
if (obj.nodeType == 'DIS' || obj.nodeType == 'MOV'){
accord._header1.enabled = true;
accord._header2.enabled = false;
} else if (obj.nodeType == 'SCR'){
accord._header1.enabled = false;
accord._header2.enabled = true;
} else {
accord._header1.enabled = false;
accord._header2.enabled = false;
}
}
//HANDLE EVENTS WHEN ACCORD IS THE SENDER
if (obj.sender != 'tree'){
if (obj.target.selectedIndex == accord.currentFrame && accord.closed != true){
accord.selectedIndex = -1;
accord.closed = true;
}
accord.treeChange = 0;
accord.closed = false;
accord.currentFrame = accord.selectedIndex;
}
//DISCLOSURE ICONS
if (obj.target.selectedIndex == -1){
obj.target._header0.icon = "icDisClosed";
tree.selectedNode.nodeName == 'DIS' ? obj.target._header1.icon = "icDisClosed" : obj.target._header1.icon = "icDisClosedDisabled"
tree.selectedNode.nodeName == 'SCR' ? obj.target._header2.icon = "icDisClosed" : obj.target._header2.icon = "icDisClosedDisabled"
txtTools._visible = false;
}
if (obj.target.selectedIndex == 0){
obj.target._header0.icon = "icDisOpen";
tree.selectedNode.nodeName == 'DIS' ? obj.target._header1.icon = "icDisClosed" : obj.target._header1.icon = "icDisClosedDisabled"
tree.selectedNode.nodeName == 'SCR' ? obj.target._header2.icon = "icDisClosed" : obj.target._header2.icon = "icDisClosedDisabled"
txtTools._visible = false;
}
if (obj.target.selectedIndex == 1){
obj.target._header0.icon = "icDisClosed";
obj.target._header1.icon = "icDisOpen";
obj.target._header2.icon = "icDisClosedDisabled";
txtTools._visible = true;
}
if (obj.target.selectedIndex == 2){
obj.target._header0.icon = "icDisClosed";
obj.target._header1.icon = "icDisClosedDisabled";
obj.target._header2.icon = "icDisOpen";
txtTools._visible = false;
}
//MAKE CONTEXT MENUS ///////////////////////////////////////////////////////////////
if (obj.target.selectedIndex == 0){ //properties
var accordMenu = new ContextMenu(getRightMouseClick);
accordMenu.hideBuiltInItems();
//accordMenu.customItems.push(new ContextMenuItem("Delete Property...", delProp));
}
if (obj.target.selectedIndex == 1){ //text
var accordMenu = new ContextMenu();
accordMenu.hideBuiltInItems();
accordMenu.customItems.push(new ContextMenuItem("Bold", boldText));
accordMenu.customItems.push(new ContextMenuItem("Italic", italicText));
accordMenu.customItems.push(new ContextMenuItem("Bullet", bulletText));
accordMenu.customItems.push(new ContextMenuItem("Colour", fontText));
var item = new ContextMenuItem("Hyperlink", linkText)
item.separatorBefore = true;
accordMenu.customItems.push(item);
accordMenu.customItems.push(new ContextMenuItem("Hot Text", hotText));
accord.menu = accordMenu;
}
if (obj.target.selectedIndex == 2){ //code
var accordMenu = new ContextMenu();
accordMenu.hideBuiltInItems();
accordMenu.customItems.push(new ContextMenuItem("Help...", launchHelp));
var item = new ContextMenuItem("Indent", indentCode)
item.separatorBefore = true;
accordMenu.customItems.push(item);
accordMenu.customItems.push(new ContextMenuItem("Outdent", outdentCode));
var item = new ContextMenuItem("Comment", commentCode)
item.separatorBefore = true;
accordMenu.customItems.push(item);
accordMenu.customItems.push(new ContextMenuItem("Uncomment", uncommentCode));
}
accord.menu = accordMenu;
}
accord.addEventListener("change", accordListener);
function launchHelp(){
_level0.helpURL = _level0.mdm_appdir+"help\\Xerte.chm";
fscommand("mdm.exec", "_level0.helpURL");
}
//right click text helpers
function boldText(){
obj = accord.textPane.textEdit;
var begin = Selection.getBeginIndex();
var end = Selection.getEndIndex();
if (begin != end){
var preStr = obj.text.substr(0,begin);
var midStr = obj.text.substr(begin, end-begin);
var postStr = obj.text.substr(end);
obj.text = preStr + '' + midStr + '' + postStr;
obj.redraw();
obj.dispatchEvent({type:"change", target:obj});
}
}
function italicText(){
obj = accord.textPane.textEdit;
var begin = Selection.getBeginIndex();
var end = Selection.getEndIndex();
if (begin != end){
var preStr = obj.text.substr(0,begin);
var midStr = obj.text.substr(begin, end-begin);
var postStr = obj.text.substr(end);
obj.text = preStr + '' + midStr + '' + postStr;
obj.redraw();
obj.dispatchEvent({type:"change", target:obj});
}
}
function bulletText(){
obj = accord.textPane.textEdit;
var begin = Selection.getBeginIndex();
var end = Selection.getEndIndex();
if (begin != end){
var preStr = obj.text.substr(0,begin);
var midStr = obj.text.substr(begin, end-begin);
var postStr = obj.text.substr(end);
obj.text = preStr + '' + midStr + '' + postStr;
obj.redraw();
obj.dispatchEvent({type:"change", target:obj});
}
}
function linkText(){
obj = accord.textPane.textEdit;
var begin = Selection.getBeginIndex();
var end = Selection.getEndIndex();
if (begin != end){
var preStr = obj.text.substr(0,begin);
var midStr = obj.text.substr(begin, end-begin);
var postStr = obj.text.substr(end);
var link = mdm.Dialogs.inputBox("Enter URL", "Enter the URL to link to:");
if (link != "false" && link != ""){
obj.text = preStr + '' + midStr + '' + postStr;
obj.redraw();
obj.dispatchEvent({type:"change", target:obj});
}
}
}
function hotText(){
obj = accord.textPane.textEdit;
var begin = Selection.getBeginIndex();
var end = Selection.getEndIndex();
if (begin != end){
var preStr = obj.text.substr(0,begin);
var midStr = obj.text.substr(begin, end-begin);
var postStr = obj.text.substr(end);
obj.text = preStr + '' + midStr + '' + postStr;
obj.redraw();
obj.dispatchEvent({type:"change", target:obj});
}
}
function fontText(){
obj = accord.textPane.textEdit;
var begin = Selection.getBeginIndex();
var end = Selection.getEndIndex();
if (begin != end){
var preStr = obj.text.substr(0,begin);
var midStr = obj.text.substr(begin, end-begin);
var postStr = obj.text.substr(end);
var col = mdm.Dialogs.inputBox("Enter Colour", "Enter the #RRGGBB colour:");
if (col != "false" && col != ""){
obj.text = preStr + '' + midStr + '' + postStr;
obj.redraw();
obj.dispatchEvent({type:"change", target:obj});
}
}
}
//right click code helpers
function indentCode(){
var code = accord.codePane.codeEdit.text;
var startIndex = code.lastIndexOf('\r', Selection.getBeginIndex());
startIndex == -1 ? startIndex = 0 : startIndex = startIndex;
var endIndex = Selection.getEndIndex();
var startStr = code.substr(0, startIndex);;
var endStr = code.substr(endIndex);
var changedStr = code.substring(startIndex, endIndex);
changedStr = ' ' + replace(changedStr, '\r', '\r ');
tempArray = changedStr.split('\r');
var resultStr = startStr + changedStr + endStr;
accord.codePane.codeEdit.text = resultStr;
//then highlight all code again
accord.codePane.codeEdit.redraw();
accord.codePane.codeEdit.label.highlightAll(startIndex + 2, endIndex + 2);
Selection.setSelection(startIndex + 2,endIndex+(2*tempArray.length));
delete tempArray;
}
function outdentCode(){
var code = accord.codePane.codeEdit.text;
var startIndex = code.lastIndexOf('\r', Selection.getBeginIndex());
startIndex == -1 ? startIndex = 0 : startIndex = startIndex;
var endIndex = Selection.getEndIndex();
var startStr = code.substr(0, startIndex);
var endStr = code.substr(endIndex);
var changedStr = code.substring(startIndex, endIndex);
changedStr = replace(changedStr, '\r ', '\r');
var resultStr = startStr + changedStr + endStr;
accord.codePane.codeEdit.text = resultStr;
//then highlight all code again
accord.codePane.codeEdit.redraw();
accord.codePane.codeEdit.label.highlightAll(startIndex, startIndex);
}
function commentCode(){
var code = accord.codePane.codeEdit.text;
var startIndex = code.lastIndexOf('\r', Selection.getBeginIndex());
startIndex == -1 ? startIndex = 0 : startIndex = startIndex;
var endIndex = Selection.getEndIndex();
var startStr = code.substr(0, startIndex);;
var endStr = code.substr(endIndex);
var changedStr = code.substring(startIndex, endIndex);
changedStr = replace(changedStr, '\r', '\r//');
tempArray = changedStr.split('\r');
var resultStr = startStr + changedStr + endStr;
accord.codePane.codeEdit.text = resultStr;
//then highlight all code again
accord.codePane.codeEdit.redraw();
accord.codePane.codeEdit.label.highlightAll(startIndex, endIndex);
Selection.setSelection(startIndex,endIndex+(2*tempArray.length));
delete tempArray;
}
function uncommentCode(){
var code = accord.codePane.codeEdit.text;
var startIndex = code.lastIndexOf('\r', Selection.getBeginIndex());
startIndex == -1 ? startIndex = 0 : startIndex = startIndex;
var endIndex = Selection.getEndIndex();
var startStr = code.substr(0, startIndex);;
var endStr = code.substr(endIndex);
var changedStr = code.substring(startIndex, endIndex);
changedStr = replace(changedStr, '//', '');
var resultStr = startStr + changedStr + endStr;
accord.codePane.codeEdit.text = resultStr;
//then highlight all code again
accord.codePane.codeEdit.redraw();
accord.codePane.codeEdit.label.highlightAll(startIndex, startIndex);
}
//property changes
propListListener = new Object();
propListListener.cellEdit = function(obj) {
//set the new value on the attribute
var propName = obj.target.getItemAt(obj.itemIndex).Property;
if (propName != undefined) {
tree.selectedItem.attributes[obj.target.getItemAt(obj.itemIndex).Property] = obj.target.getItemAt(obj.itemIndex).Value;
tree.refresh();
}
mdm.setwindowtitle('XERTE '+ contentXML.fileName + '*');
};
propListListener.cellFocusIn = function(obj) {
obj.target.cellEditor.restrict = '^<>"';
};
propListListener.cellFocusOut = function(obj) {
if (obj.target.getItemAt(obj.itemIndex).Value == 'Enter Value...'){
mdm.prompt("You must enter a value for the property");
};
};
propListListener.itemRollOver = function(obj) {
obj.target.rolledOverIndex = obj.index;
};
propListListener.change = function(obj){
//only allow optional properties to be deleted
//so if the property is in the combo box item, it can be deleted - all others are mandatory
//what about custom properties? Leave this for now...
//accord.propPane.delProp.enabled = false;
if (tree.selectedNode.nodeName != 'BIN'){
for (var i = 0; i < accord.propPane.optProps.length; i++){
if (accord.propPane.optProps.getItemAt(i).label == accord.propPane.propEdit.getItemAt(accord.propPane.propEdit.selectedIndex).Property){
accord.propPane.delProp.enabled = true;
break;
}
}
} else {
accord.propPane.delProp.enabled = true;
}
};
accord.propPane.propEdit.addEventListener("change", propListListener);
accord.propPane.propEdit.addEventListener("cellEdit", propListListener);
accord.propPane.propEdit.addEventListener("cellFocusIn", propListListener);
accord.propPane.propEdit.addEventListener("cellFocusOut", propListListener);
accord.propPane.propEdit.addEventListener("itemRollOver", propListListener);
//add properties to node
addPropListener = new Object();
addPropListener.click = function(obj) {
//add the property...
if (tree.selectedItem.attributes[accord.propPane.optProps.value] == undefined) {
if (tree.selectedItem.nodeName == 'RES' && accord.propPane.optProps.value == 'tabIndex') {
tree.selectedItem.attributes[accord.propPane.optProps.value] = tree.selectedItem.index()+21;
} else {
tree.selectedItem.attributes[accord.propPane.optProps.value] = "Enter Value...";
}
//refresh the display
accord.propPane.propEdit.removeAll();
//loop through attributes and put each one on the control
var atts = tree.selectedItem.attributes;
for (var i in atts) {
var obj = {Property:i, Value:atts[i]};
if (obj.Property != 'type') {
accord.propPane.propEdit.addItem(obj);
}
}
accord.propPane.propEdit.selectedIndex = 0;
accord.propPane.propEdit.focusedCell = {columnIndex:1, itemIndex:0};
accord.propPane.propEdit.dispatchEvent({type:"change", target:accord.propPane.propEdit});
mdm.setwindowtitle('XERTE '+ contentXML.fileName + '*');
}
};
accord.propPane.addProp.addEventListener("click", addPropListener);
delPropListener = new Object();
delPropListener.click = function(obj) {
delProp();
};
accord.propPane.delProp.addEventListener("click", delPropListener);
//get text changes
textListener = new Object();
textListener.change = function(obj){
undoManager.undoStack.push(obj.target.text);
tree.selectedItem.firstChild.nodeValue = obj.target.text;
obj.target.label.highlightHTML();
mdm.setwindowtitle('XERTE '+ contentXML.fileName + '*');
};
textListener.focusIn = function(obj) {
undoManager.currentObject = "textEdit";
};
textListener.focusOut = function(obj) {
undoManager.currentObject = "";
};
accord.textPane.textEdit.addEventListener("change", textListener);
accord.textPane.textEdit.addEventListener("focusIn", textListener);
accord.textPane.textEdit.addEventListener("focusOut", textListener);
//get code changes...
codeListener = new Object();
codeListener.change = function(obj){
undoManager.undoStack.push(obj.target.text);
tree.selectedItem.firstChild.nodeValue = obj.target.text;
obj.target.label.highlightCode();
mdm.setwindowtitle('XERTE '+ contentXML.fileName + '*');
}
codeListener.focusIn = function(){
undoManager.currentObject = "codeEdit";
editor.hintCode = true;
}
codeListener.focusOut = function(){
undoManager.currentObject = "";
editor.codeHint.removeMovieClip();
editor.hintCode = false;
}
accord.codePane.codeEdit.addEventListener("change", codeListener);
accord.codePane.codeEdit.addEventListener("focusIn", codeListener);
accord.codePane.codeEdit.addEventListener("focusOut", codeListener);
//undo function
function undo(){
if (undoManager.undoStack.length > 1){
if (undoManager.currentObject == "textEdit"){
undoManager.undoStack.pop();
tree.selectedItem.firstChild.nodeValue = accord.textPane.textEdit.text = undoManager.undoStack[undoManager.undoStack.length - 1];
accord.textPane.textEdit.redraw();
accord.textPane.textEdit.label.highlight(0, accord.textPane.textEdit.label.text.length);
}
if (undoManager.currentObject == "codeEdit"){
undoManager.undoStack.pop();
tree.selectedItem.firstChild.nodeValue = accord.codePane.codeEdit.text = undoManager.undoStack[undoManager.undoStack.length - 1];
accord.codePane.codeEdit.redraw();
accord.codePane.codeEdit.label.highlightAll();
}
}
}
//make the context menu with the right options/////////////////////////////////////////
function makeContextMenu(nodeType) {
var treeMenu = new ContextMenu(getRightMouse);
treeMenu.hideBuiltInItems();
if (nodeType == 'LO') {
treeMenu.customItems.push(new ContextMenuItem("Add Setup Script", addSetupScr));
}
if (nodeType == 'IFC' || nodeType == 'FW') {
treeMenu.customItems.push(new ContextMenuItem("Add Page...", addPg));
treeMenu.customItems.push(new ContextMenuItem("Add Entry Frame...", addFwEnt));
var item = new ContextMenuItem("Add Page Template...", addPageTemplate);
item.separatorBefore = true;
treeMenu.customItems.push(item);
}
if (nodeType == 'PG' || nodeType == 'FW_ENT' || nodeType == 'RES' || nodeType == 'KO') {
treeMenu.customItems.push(new ContextMenuItem("Add Graphic...", addDis));
treeMenu.customItems.push(new ContextMenuItem("Add Text...", addABC));
treeMenu.customItems.push(new ContextMenuItem("Add Draw...", addDrw));
treeMenu.customItems.push(new ContextMenuItem("Add Sound...", addSnd));
treeMenu.customItems.push(new ContextMenuItem("Add Movie...", addMov));
treeMenu.customItems.push(new ContextMenuItem("Add Interaction...", addInt));
treeMenu.customItems.push(new ContextMenuItem("Add Framework...", addFW));
treeMenu.customItems.push(new ContextMenuItem("Add Decision...", addDec));
treeMenu.customItems.push(new ContextMenuItem("Add Component...", addCom));
treeMenu.customItems.push(new ContextMenuItem("Add Script...", addScr));
}
if (nodeType == 'KO') {
var item = new ContextMenuItem("Run Wizard...", runKOWizard);
item.separatorBefore = true;
treeMenu.customItems.push(item);
}
if (nodeType == 'DEC') {
treeMenu.customItems.push(new ContextMenuItem("Add Page...", addPg));
}
if (nodeType == 'INT') {
treeMenu.customItems.push(new ContextMenuItem("Add Label...", addLab));
treeMenu.customItems.push(new ContextMenuItem("Add Button...", addBut));
treeMenu.customItems.push(new ContextMenuItem("Add Radio Button...", addRad));
treeMenu.customItems.push(new ContextMenuItem("Add CheckBox...", addChk));
treeMenu.customItems.push(new ContextMenuItem("Add ComboBox...", addCbo));
treeMenu.customItems.push(new ContextMenuItem("Add HotObject...", addHO));
treeMenu.customItems.push(new ContextMenuItem("Add HotSpot...", addHS));
treeMenu.customItems.push(new ContextMenuItem("Add TextEntry...", addTxt));
treeMenu.customItems.push(new ContextMenuItem("Add TargetArea...", addTar));
//treeMenu.customItems.push(new ContextMenuItem("Add KeyPress...", addKey));
treeMenu.customItems.push(new ContextMenuItem("Add TimeLimit...", addTime));
treeMenu.customItems.push(new ContextMenuItem("Add TriesLimit...", addTries));
treeMenu.customItems.push(new ContextMenuItem("Add Event...", addEvent));
//reached limit for interactions
}
if (nodeType == 'SND') {
treeMenu.customItems.push(new ContextMenuItem("Add Page", addPg));
}
if (nodeType == 'BIN') {
treeMenu.customItems.push(new ContextMenuItem("Empty Trash", delTrash));
}
//add items that are always present...
if (nodeType != 'LO' && nodeType != 'IFC' && nodeType != 'FW_ENT' && nodeType != 'BIN') {
var item = new ContextMenuItem("Duplicate Icon...", duplicateNode);
item.separatorBefore = true;
treeMenu.customItems.push(item);
}
if (nodeType != 'LO' && nodeType != 'IFC' && nodeType != 'BIN') {
var item = new ContextMenuItem("Delete Icon...", deleteNode);
item.separatorBefore = true;
treeMenu.customItems.push(item);
}
//edit option for images
if (nodeType == 'DIS') {
var item = new ContextMenuItem("Edit Image...", editImage);
item.separatorBefore = true;
treeMenu.customItems.push(item);
}
//apply it to the tree
dndtree.menu = treeMenu;
}
function getRightMouse() {
//if right mouse is clicked, we want to select the rolled-over item
tree.selectedIndex = tree.rolledOverIndex;
tree.dispatchEvent({type:"change", target:tree});
}
//make the combo box with correct properties/////////////////////////////////////////////////
function makeComboMenu(nodeType, subType) {
if (nodeType == 'DIS') {
if (subType == 'text'){
accord.propPane.optProps.removeAll();
accord.propPane.optProps.addItem('id');
accord.propPane.optProps.addItem('w');
accord.propPane.optProps.addItem('h');
accord.propPane.optProps.addItem('scrolling');
accord.propPane.optProps.addItem('tabIndex');
accord.propPane.optProps.addItem('transition');
accord.propPane.optProps.addItem('textColour');
accord.propPane.optProps.addItem('textSize');
accord.propPane.optProps.addItem('textFont');
accord.propPane.optProps.addItem('textIcon');
accord.propPane.optProps.addItem('embedFonts');
accord.propPane.optProps.addItem('embedVars');
accord.propPane.optProps.addItem('initObject');
accord.propPane.addProp.enabled = true;
} else {
accord.propPane.optProps.removeAll();
accord.propPane.optProps.addItem('id');
accord.propPane.optProps.addItem('w');
accord.propPane.optProps.addItem('h');
accord.propPane.optProps.addItem('url');
accord.propPane.optProps.addItem('controls');
accord.propPane.optProps.addItem('autoPlay');
accord.propPane.optProps.addItem('tabIndex');
accord.propPane.optProps.addItem('transition');
accord.propPane.optProps.addItem('toolTip');
accord.propPane.optProps.addItem('initObject');
accord.propPane.addProp.enabled = true;
}
}
if (nodeType == 'SND') {
accord.propPane.optProps.removeAll();
accord.propPane.optProps.addItem('id');
accord.propPane.optProps.addItem('controls');
accord.propPane.optProps.addItem('eraseChildren');
accord.propPane.optProps.addItem('eraseOnReset');
accord.propPane.optProps.addItem('stream');
accord.propPane.addProp.enabled = true;
}
if (nodeType == 'MOV') {
accord.propPane.optProps.removeAll();
accord.propPane.optProps.addItem('id');
accord.propPane.optProps.addItem('w');
accord.propPane.optProps.addItem('h');
accord.propPane.optProps.addItem('tabIndex');
accord.propPane.addProp.enabled = true;
}
if (nodeType == 'INT') {
accord.propPane.optProps.removeAll();
accord.propPane.optProps.addItem('id');
accord.propPane.optProps.addItem('constrainDragItems');
accord.propPane.addProp.enabled = true;
}
if (nodeType == 'FW') {
accord.propPane.optProps.removeAll();
accord.propPane.optProps.addItem('id');
accord.propPane.optProps.addItem('swf');
accord.propPane.optProps.addItem('ifc');
accord.propPane.addProp.enabled = true;
}
if (nodeType == 'DEC') {
accord.propPane.optProps.removeAll();
accord.propPane.optProps.addItem('id');
accord.propPane.optProps.addItem('path');
accord.propPane.addProp.enabled = true;
}
if (nodeType == 'FW_ENT') {
accord.propPane.optProps.removeAll();
accord.propPane.optProps.addItem('id');
accord.propPane.optProps.addItem('model');
accord.propPane.addProp.enabled = true;
}
if (nodeType == 'PG' || nodeType == 'KO') {
accord.propPane.optProps.removeAll();
accord.propPane.optProps.addItem('id');
accord.propPane.optProps.addItem('title');
accord.propPane.optProps.addItem('help');
accord.propPane.optProps.addItem('synchPoint');
accord.propPane.optProps.addItem('model');
accord.propPane.optProps.addItem('transition');
accord.propPane.optProps.addItem('templateData');
accord.propPane.addProp.enabled = true;
}
if (nodeType == 'LO'){
accord.propPane.optProps.removeAll();
accord.propPane.optProps.addItem('titleBarColour');
accord.propPane.optProps.addItem('statusBarColour');
accord.propPane.optProps.addItem('fillColour');
accord.propPane.optProps.addItem('defaultFont');
accord.propPane.optProps.addItem('defaultSize');
accord.propPane.optProps.addItem('defaultColour');
accord.propPane.optProps.addItem('defaultBold');
accord.propPane.optProps.addItem('selectableText');
accord.propPane.optProps.addItem('embedFonts');
accord.propPane.optProps.addItem('buttonFillColour');
accord.propPane.optProps.addItem('buttonTextColour');
accord.propPane.optProps.addItem('glossaryColour');
accord.propPane.optProps.addItem('labelColour');
accord.propPane.optProps.addItem('inputFont');
accord.propPane.optProps.addItem('inputSize');
accord.propPane.optProps.addItem('inputColour');
accord.propPane.optProps.addItem('inputBold');
accord.propPane.optProps.addItem('pageTitleFont');
accord.propPane.optProps.addItem('pageTitleSize');
accord.propPane.optProps.addItem('pageTitleColour');
accord.propPane.optProps.addItem('pageTitleBold');
accord.propPane.optProps.addItem('statusFont');
accord.propPane.optProps.addItem('statusSize');
accord.propPane.optProps.addItem('statusColour');
accord.propPane.optProps.addItem('statusBold');
accord.propPane.optProps.addItem('titleFont');
accord.propPane.optProps.addItem('titleSize');
accord.propPane.optProps.addItem('titleColour');
accord.propPane.optProps.addItem('titleBold');
accord.propPane.optProps.addItem('stageColour');
accord.propPane.optProps.addItem('stageSize');
accord.propPane.optProps.addItem('templateData');
accord.propPane.optProps.addItem('styleSheet');
accord.propPane.addProp.enabled = true;
}
if (nodeType == 'RES') {
accord.propPane.optProps.removeAll();
accord.propPane.optProps.addItem('id');
accord.propPane.optProps.addItem('rs');
accord.propPane.optProps.addItem('tabIndex');
if (tree.selectedItem.attributes.type == 'button'){
accord.propPane.optProps.addItem('swf');
accord.propPane.optProps.addItem('toolTip');
accord.propPane.optProps.addItem('enabled');
accord.propPane.optProps.addItem('visible');
}
if (tree.selectedItem.attributes.type == 'combo'){
accord.propPane.optProps.addItem('data');
}
if (tree.selectedItem.attributes.type == 'button' || tree.selectedNode.attributes.type == 'combo') {
accord.propPane.optProps.addItem('w');
accord.propPane.optProps.addItem('h');
}
if (tree.selectedItem.attributes.type == 'radio' || tree.selectedNode.attributes.type == 'checkBox') {
accord.propPane.optProps.addItem('w');
accord.propPane.optProps.addItem('textColour');
accord.propPane.optProps.addItem('enabled');
accord.propPane.optProps.addItem('visible');
}
if (tree.selectedItem.attributes.type == 'label') {
accord.propPane.optProps.addItem('textColour');
}
if (tree.selectedItem.attributes.type == 'textEntry') {
accord.propPane.optProps.addItem('border');
accord.propPane.optProps.addItem('background');
accord.propPane.optProps.addItem('inputFont');
accord.propPane.optProps.addItem('inputSize');
accord.propPane.optProps.addItem('inputColour');
accord.propPane.optProps.addItem('inputBold');
accord.propPane.optProps.addItem('matchCase');
}
if (tree.selectedItem.attributes.type == 'hotSpot') {
accord.propPane.optProps.addItem('highlight');
}
accord.propPane.optProps.addItem('correct');
accord.propPane.addProp.enabled = true;
}
if (nodeType == 'SCR') {
accord.propPane.optProps.removeAll();
accord.propPane.optProps.addItem('id');
accord.propPane.optProps.addItem('isFunc');
accord.propPane.addProp.enabled = true;
}
if (nodeType == 'IFC') {
accord.propPane.optProps.removeAll();
accord.propPane.optProps.addItem('swf');
accord.propPane.optProps.addItem('helpfile');
accord.propPane.optProps.addItem('displayMode');
accord.propPane.optProps.addItem('scorm2004Choice');
accord.propPane.optProps.addItem('scorm2004Flow');
accord.propPane.addProp.enabled = true;
}
if (nodeType == 'COM') {
accord.propPane.optProps.removeAll();
accord.propPane.optProps.addItem('id');
accord.propPane.optProps.addItem('x');
accord.propPane.optProps.addItem('y');
accord.propPane.addProp.enabled = true;
}
}
//context menu functions/////////////////////////////////////////////////////////////////////////////
function addDis() {
tree.selectedItem.appendChild(new XML('').firstChild);
finishAddingNode();
}
function editImage() {
//which file? we have url = FileLocation + 'image.jpg' for example
var fileToEdit = tree.selectedItem.attributes.url;
fileToEdit = replace(fileToEdit, 'FileLocation + ', editor.FileLocation.substr(0, editor.FileLocation.lastIndexOf('\\')+1));
fileToEdit = replace(fileToEdit, "'", "");
fileToEdit = replace(fileToEdit, "/", "\\");
mdm.System.exec(fileToEdit);
}
function addABC() {
tree.selectedItem.appendChild(new XML('').firstChild);
finishAddingNode();
}
function addDrw() {
tree.selectedItem.appendChild(new XML('').firstChild);
finishAddingNode();
}
function addSnd() {
tree.selectedItem.appendChild(new XML('').firstChild);
finishAddingNode();
}
function addMov() {
tree.selectedItem.appendChild(new XML('').firstChild);
finishAddingNode();
}
function addInt() {
tree.selectedItem.appendChild(new XML('').firstChild);
finishAddingNode();
}
function addFW() {
tree.selectedItem.appendChild(new XML('').firstChild);
finishAddingNode();
}
function addDec() {
tree.selectedItem.appendChild(new XML('').firstChild);
finishAddingNode();
}
function addScr() {
tree.selectedItem.appendChild(new XML('').firstChild);
finishAddingNode();
}
function addSetupScr() {
tree.selectedItem.insertBefore(new XML('').firstChild, tree.selectedItem.firstChild);
finishAddingNode();
}
function addCom() {
tree.selectedItem.appendChild(new XML('').firstChild);
finishAddingNode();
}
function addFwEnt() {
if (tree.selectedNode.childNodes.length>0) {
tree.selectedItem.insertBefore(new XML('').firstChild, tree.selectedItem.firstChild);
finishAddingNode();
} else {
tree.selectedItem.appendChild(new XML('').firstChild);
finishAddingNode();
}
}
function addPg() {
tree.selectedItem.appendChild(new XML('').firstChild);
finishAddingNode();
}
function addKO() {
tree.selectedItem.appendChild(new XML('').firstChild);
finishAddingNode();
}
function delTrash() {
var tempNode = tree.selectedItem.cloneNode(false);
deleteNode();
contentXML.firstChild.appendChild(tempNode);
tree.dataProvider = tree.dataProvider;
tree.selectedNode = tempNode;
tree.dispatchEvent({type:"change", target:tree});
}
function addLab(){
tree.selectedItem.appendChild(new XML('').firstChild);
finishAddingNode();
}
function addBut(){
var type = tree.selectedItem.lastChild.attributes.type;
if (tree.selectedItem.lastChild.nodeName == 'RES' && (type == 'button' || type == 'radio' || type == 'checkBox' || type == 'label')){
tree.selectedItem.appendChild(new XML('').firstChild);
} else {
tree.selectedItem.appendChild(new XML('').firstChild);
}
finishAddingNode();
}
function addRad() {
var type = tree.selectedItem.lastChild.attributes.type;
if (tree.selectedItem.lastChild.nodeName == 'RES' && (type == 'radio' || type == 'label')){
tree.selectedItem.appendChild(new XML('').firstChild);
} else {
tree.selectedItem.appendChild(new XML('').firstChild);
}
finishAddingNode();
}
function addChk() {
var type = tree.selectedItem.lastChild.attributes.type;
if (tree.selectedItem.lastChild.nodeName == 'RES' && (type == 'checkBox' || type == 'label')){
tree.selectedItem.appendChild(new XML('').firstChild);
} else {
tree.selectedItem.appendChild(new XML('').firstChild);
}
finishAddingNode();
}
function addCbo() {
var type = tree.selectedItem.lastChild.attributes.type;
if (tree.selectedItem.lastChild.nodeName == 'RES' && type == 'combo'){
tree.selectedItem.appendChild(new XML('').firstChild);
} else if (tree.selectedItem.lastChild.nodeName == 'RES' && type == 'label'){
tree.selectedItem.appendChild(new XML('').firstChild);
} else {
tree.selectedItem.appendChild(new XML('').firstChild);
}
finishAddingNode();
}
function addHS() {
tree.selectedItem.appendChild(new XML('').firstChild);
finishAddingNode();
}
function addHO() {
tree.selectedItem.appendChild(new XML('').firstChild);
finishAddingNode();
}
function addTxt() {
tree.selectedItem.appendChild(new XML('').firstChild);
finishAddingNode();
}
function addTar() {
tree.selectedItem.appendChild(new XML('').firstChild);
finishAddingNode();
}
function addKey() {
tree.selectedItem.appendChild(new XML('').firstChild);
finishAddingNode();
}
function addTime() {
tree.selectedItem.appendChild(new XML('').firstChild);
finishAddingNode();
}
function addTries() {
tree.selectedItem.appendChild(new XML('').firstChild);
finishAddingNode();
}
function addEvent() {
tree.selectedItem.appendChild(new XML('').firstChild);
finishAddingNode();
}
function finishAddingNode() {
tree.dataProvider = tree.dataProvider;
tree.setIsOpen(tree.selectedNode, true);
tree.selectedNode = tree.selectedItem.getTreeNodeAt(tree.selectedItem.childNodes.length-1);
//fire the change event
tree.dispatchEvent({type:'change', target:tree});
//select the name property for easy typing...
accord.selectedIndex = 0;
accord.propPane.propEdit.focusedCell = {columnIndex:1, itemIndex:0};
mdm.setwindowtitle('XERTE '+ contentXML.fileName + '*');
}
function duplicateNode() {
//'paste' the existing node right under the current node;
//user can move manually if required...
var currentNode = tree.selectedNode;
var dupedNode = tree.selectedNode.cloneNode(true);
var parent = tree.selectedNode.parentNode;
parent.insertBefore(dupedNode, currentNode);
//select the new node...
tree.dataProvider = tree.dataProvider;
tree.selectedNode = currentNode;//?weird - it should surely be currentNode.nextSibling?
tree.dispatchEvent({type:'change', target:tree});
mdm.setwindowtitle('XERTE '+ contentXML.fileName + '*');
}
function deleteNode() {
var tempNode = tree.selectedItem.cloneNode(true);
var parentNode = tree.selectedItem.parentNode;
tree.selectedItem.removeNode();
if (contentXML.firstChild.lastChild.nodeName == 'BIN') {
contentXML.firstChild.lastChild.appendChild(tempNode);
}
tree.dataProvider = tree.dataProvider;
tree.selectedNode = parentNode;
mdm.setwindowtitle('XERTE '+ contentXML.fileName + '*');
tree.dispatchEvent({target:tree, type:'change'});
}
function runKOWizard() {
//save this file
saveFile();
//open the wizard form
if (tree.selectedNode.attributes.templateData != ""){
wizWinID = setInterval(wizardToFront, 50);
//init and pass in the wizard and the file name
mdm.form_callfunction("wizard", "init", tree.selectedItem.attributes.templateData+"|"+editor.FileLocation, "|");
}
}
function wizardToFront(){
clearInterval(wizWinID);
mdm.Forms.Wizard.show();
}
function setDrawingData(xmlData){
if (tree.selectedItem.nodeName == 'DRW'){
tree.selectedItem.firstChild.nodeValue = xmlData;
}
}
function saveFile() {
var timer = getTimer();
var xmlStr = contentXML.format();
if (xmlStr == 'undefined'){
mdm.prompt("Error saving file. The file was not saved");
return;
}
//unsure why this replace is here - but it takes ages, so removed it.
//Assuming it is concerned simply with formatting, so left here in case of problems...
//replace(xmlStr, '\r\r', '\r');
events.xmlStr = xmlStr;
fscommand('mdm.saveToFile_unicode', 'contentXML.fileName,events.xmlStr');
mdm.setwindowtitle('XERTE '+ contentXML.fileName);
}
function saveModel() {
modelXMLStr = tree.selectedItem.format();
fscommand('mdm.saveToFile_unicode', 'modelFile,modelXMLStr');
}
function getModelFile() {
mdm.browsefiledir(launchPath+"components\\");
mdm.browsefiletitle('Insert Model...');
mdm.browsefile_buttontext('Insert');
mdm.browsefile_filterlist('Model Files|*.rlm');
fscommand("mdm.browseFile", "events.modelFileOpen");
}
function insertModel(modelFile) {
modelXML.load(modelFile);
mdm.setwindowtitle('XERTE '+ contentXML.fileName + '*');
}
function addPageTemplate(){
//browse the templates in the xtp folder
mdm.Dialogs.BrowseFile.title = "Please select a template";
mdm.Dialogs.BrowseFile.defaultDirectory = mdm.Application.path+'wizards';
mdm.Dialogs.BrowseFile.defaultExtension = "xcp";
mdm.Dialogs.BrowseFile.dialogText = "Select a template for a new project";
mdm.Dialogs.BrowseFile.filterList = "Xerte Template Packs|*.xcp";
mdm.Dialogs.BrowseFile.filterText = "Xerte Template Packs|*.xcp";
var packageFile = mdm.Dialogs.BrowseFile.show();
if (packageFile != false){
insertPageTemplate(packageFile);
}
}
function insertPageTemplate(packageFile){
if (tree.selectedNode.nodeName != 'FW' && tree.selectedNode.nodeName != 'IFC')
{
mdm.Dialogs.prompt("You can only add page templates to the interface or framework icons");
return;
}
if (editor.FileLocation == "")
{
var newFile = mdm.Dialogs.prompt("You must create a new file before inserting page templates.");
return;
}
//get the folder to unzip it to
if (packageFile != "false"){
mdm.Dialogs.BrowseFolder.defaultDirectory = editor.FileLocation.substr(0, editor.FileLocation.lastIndexOf('\\') + 1);
mdm.Dialogs.BrowseFolder.title = "The template needs to copy files to your project. Select an empty folder for these files."
destFolder = mdm.Dialogs.BrowseFolder.show();
}
if (packageFile != "false" && destFolder != "false")
{
//unzip the pack into the folder...
var files = mdm.FileSystem.getFileList(destFolder, "*.*");
var res = true;
if (files.length > 0){
var res = mdm.Dialogs.promptModal("That folder is not empty. Are you sure you want to use it? ", "yesno", "confirm");
}
if (res == true){
var fsparams = '"'+packageFile+"\",\""+destFolder+"\",\"*.*\",\"none\"";
fscommand("flashvnn.ExtractZip", fsparams);
//need to pause whilst the fscommand finishes
var res = mdm.Dialogs.promptModal("Open the wizard? ", "yesno", "confirm");
//if the 'common' folder exists, copy it to filelocation
if (mdm.FileSystem.FolderExists(destFolder + 'common')){
var commonFiles = mdm.FileSystem.getFileList(destFolder + 'common', "*.*");
if (mdm.FileSystem.folderExists(editor.FileLocation.substr(0, editor.FileLocation.lastIndexOf('\\') + 1) + "common")){
for (var i = 0; i < commonFiles.length; i++){
if (!mdm.FileSystem.fileExists(editor.FileLocation.substr(0, editor.FileLocation.lastIndexOf('\\') + 1) + 'common\\' + commonFiles[i])){
mdm.FileSystem.copyFile(destFolder + 'common\\' + commonFiles[i], editor.FileLocation.substr(0, editor.FileLocation.lastIndexOf('\\') + 1) + "common\\" + commonFiles[i]);
}
}
} else { //copy the whole folder, as it doesn't already exist
mdm.FileSystem.copyFolder(destFolder + 'common', editor.FileLocation.substr(0, editor.FileLocation.lastIndexOf('\\') + 1) + "common");
}
}
//then delete the folder
mdm.FileSystem.deleteFolder(destFolder + 'common', "noask");
var modelFile = destFolder + mdm.FileSystem.getFileList(destFolder, "*.rlm");
var modelXMl = new XML();
modelXML.ignoreWhite = true;
modelXML.load(modelFile);
modelXML.launch = res;
modelXML.rlmFile = modelFile;
modelXML.onLoad = function(){
var str1 = modelFile.substr(0, modelFile.lastIndexOf('\\') + 1);
var str2 = editor.FileLocation.substr(0, editor.FileLocation.lastIndexOf('\\') + 1);
tdStr = "FileLocation + '" + str1.substr(str2.length) + modelFile.substr(str1.length) + "'";
tdStr = replace(tdStr, '.rlm', '.xml');
tdStr = replace(tdStr, '\\', '/');
this.firstChild.attributes.templateData = tdStr;
tree.dataProvider.firstChild.firstChild.appendChild(this.firstChild);
tree.dataProvider = tree.dataProvider;
tree.selectedNode = tree.dataProvider.firstChild.firstChild.lastChild;
tree.dispatchEvent({type:'change', target:tree});
if (this.launch == true){
runKOWizard();
}
}
}
}
}
function newTemplateProject(){
//browse the templates in the xtp folder
mdm.Dialogs.BrowseFile.title = "Please select a template";
mdm.Dialogs.BrowseFile.defaultDirectory = mdm.Application.path+'xtp';
mdm.Dialogs.BrowseFile.defaultExtension = "xtp";
mdm.Dialogs.BrowseFile.dialogText = "Select a template for a new project";
mdm.Dialogs.BrowseFile.filterList = "Xerte Template Packs|*.xtp";
mdm.Dialogs.BrowseFile.filterText = "Xerte Template Packs|*.xtp";
var packageFile = mdm.Dialogs.BrowseFile.show();
//get the folder to unzip it to
if (packageFile != "false"){
makeTemplateProject(packageFile);
}
}
function makeTemplateProject(packageFile){
clearInterval(intID);
mdm.Dialogs.BrowseFolder.defaultDirectory = mdm.System.Paths.desktop;
mdm.Dialogs.BrowseFolder.title = "Select or create a folder for the new project:"
destFolder = mdm.Dialogs.BrowseFolder.show();
if (destFolder != "false"){
//unzip the pack into the folder...
var files = mdm.FileSystem.getFileList(destFolder, "*.*");
var res = true;
if (files.length > 0){
var res = mdm.Dialogs.promptModal("That folder is not empty. Are you sure you want to use it for the new project? ", "yesno", "confirm");
}
if (res == true){
var fsparams = '"'+packageFile+"\",\""+destFolder+"\",\"*.*\",\"none\"";
fscommand("flashvnn.ExtractZip", fsparams);
var open = mdm.Dialogs.promptModal("Do you want to open the new project?", "yesno", "confirm");
if (open != false){
intID = setInterval(openTemplateProject, 2000, destFolder + mdm.FileSystem.getFileList(destFolder, "*.rlt"));
}
}
}
}
function openTemplateProject(fileName){
clearInterval(intID);
events.fileName = fileName;
}
function createTemplatePackage(){
var sourceFolder = editor.FileLocation.substr(0, editor.FileLocation.lastIndexOf('\\')+1);
//have we got an rlo or rlt, an xml and an xwd?
var files = mdm.FileSystem.getFileList(sourceFolder , '*.*').join();
if (files.indexOf('.xml') == -1 || files.indexOf('.xwd') == - 1){
mdm.prompt('Some files required for the package are missing. See Help.');
return;
}
var fileList = mdm.FileSystem.getFileList(launchPath+'swfmill\\lib', "*.*");
mdm.Dialogs.BrowseFile.title = "Create a new Template Package";
mdm.Dialogs.BrowseFile.defaultDirectory = mdm.System.Paths.desktop
mdm.Dialogs.BrowseFile.defaultExtension = "xtp";
mdm.Dialogs.BrowseFile.dialogText = "Save the template Package as:";
mdm.Dialogs.BrowseFile.filterList = "Xerte Template Packs|*.xtp";
mdm.Dialogs.BrowseFile.filterText = "Xerte Template Packs|*.xtp";
var packageFile = mdm.Dialogs.BrowseFile.show();
if (packageFile != "false"){
if (packageFile.indexOf('.xtp') == -1) packageFile += '.xtp';
//zip the folder
var destZip = packageFile;
var sourceFolder = editor.FileLocation.substr(0, editor.FileLocation.lastIndexOf('\\')+1);
var fsparams = '"'+packageFile+"\",\""+sourceFolder+"\",\"*.*\",\"none\"";
fscommand("flashvnn.ZipFolder", fsparams);
fscommand("flashvnn.CloseZip", "");
mdm.prompt("Template Package Created.");
}
}
function createPageTemplate(){
//get output file
mdm.Dialogs.BrowseFile.title = "Create a new Page Template";
mdm.Dialogs.BrowseFile.defaultDirectory = mdm.Application.path+'xcp';
mdm.Dialogs.BrowseFile.defaultExtension = "xcp";
mdm.Dialogs.BrowseFile.dialogText = "Save the page template as:";
mdm.Dialogs.BrowseFile.filterList = "Xerte Component|*.xcp";
mdm.Dialogs.BrowseFile.filterText = "Xerte Component|*.xcp";
var packageFile = mdm.Dialogs.BrowseFile.show();
//save the selected page as a model in the same folder as the xml and xwd files, with the same names as those files as convention
var attr = tree.selectedNode.attributes.templateData
modelFile = attr.substr(attr.indexOf("'") + 1);
modelFile = editor.FileLocation.substr(0, editor.FileLocation.lastIndexOf('//') + 1) + modelFile.substr(0, modelFile.lastIndexOf('.')) + '.rlm';
//save the model
saveModel();
}
function installTemplatePackage(){
//browse for the package
mdm.Dialogs.BrowseFile.title = "Install Template Package:";
mdm.Dialogs.BrowseFile.defaultDirectory = mdm.System.Paths.desktop;
mdm.Dialogs.BrowseFile.defaultExtension = "xtp";
mdm.Dialogs.BrowseFile.dialogText = "Install Template Package:";
mdm.Dialogs.BrowseFile.filterList = "Xerte Template Packs|*.xtp";
mdm.Dialogs.BrowseFile.filterText = "Xerte Template Packs|*.xtp";
var packageFile = mdm.Dialogs.BrowseFile.show();
if (packageFile != 'false'){
if (packageFile.indexOf('.xtp' == -1)){
mdm.prompt("Invalid File Format");
return;
} else {
var fileName = packageFile.substring(packageFile.lastIndexOf('\\') + 1, packageFile.length);
mdm.FileSystem.copyFile(packageFile, mdm.Application.path+"wizards\\" + fileName);
templatesMenu.removeAll();
addTemplatesToMenu();
mdm.prompt('Template Installed');
}
}
}
XMLNode.prototype.getChildByNodeName = function(nodeName){
for (var i = 0; i < this.childNodes.length; i++){
if (this.childNodes[i].nodeName == nodeName) return this.childNodes[i];
}
}
//from layer51.com [excellent site for object prototype extensions...]
//create the XML string - can adapt to remove tabs / lines and remove any
//editor specific xml attributes - i.e. 'name'
XML.prototype.__proto__.format = function(t) {
var a, i, s;
if (t == undefined) {
t = '\t';
}
if (this.nodeName == null) {
s = this.firstChild.format(t);
return s;
}
s = "<"+this.nodeName;
for (a in this.attributes) {
s += " "+a+"=\""+this.attributes[a]+"\"";
}
if (!this.hasChildNodes()) {
s += " />";
return t+s+"\r";
//newline;
}
s += ">";
if (this.firstChild.nodeType == 3) {
s += '';
} else {
s += "\r";
//newline;
for (i=0; i";
return t+s+"\r";
//newline;
};
//replace helper...
function replace(the_string, search_string, replace_string) {
var found = 0;
var pos = the_string.indexOf(search_string);
while (pos>=0) {
found++;
var start_string = the_string.substr(0, pos);
var end_string = the_string.substr(pos+search_string.length);
the_string = start_string+replace_string+end_string;
pos = the_string.indexOf(search_string, pos+replace_string.length);
}
return the_string;
}
XMLNode.prototype.clip = function() {
if (this.nodeName != 'RES') {
return eval(this.attributes.id);
} else {
return eval(this.attributes.rs);
}
};
//highlight HTML////////////////////////////////////////////////////////////////////
accord.textPane.textEdit.label.highlightHTML = function() {
//see highlighter.fla for this code, slightly modified.
//we only need to highlight a small section of the string around the caret
//otherwise we call highlight with the whole string from elsewhere - when set when tree changes, or when text pasted
var myString = this.text;
var caret = Selection.getCaretIndex()-1;
var start;
var end;
var nextOpen = myString.indexOf('<', caret);
var nextClosed = myString.indexOf('>', caret);
var prevOpen = myString.lastIndexOf('<', caret);
var prevClosed = myString.lastIndexOf('>', caret);
if (nextClosedthis.prevLength + 1) {
//text pasted
this.highlight(0, this.text.length);
} else {
this.highlight(start, end);
}
this.prevLength = this.text.length;
//save length for checking for pastes.
};
accord.textPane.textEdit.label.highlight = function(start, end) {
timer = getTimer();
var myString = this.text;
var myTag = "";
var startIndex = start;
var endIndex;
var tagStart;
var tagEnd;
var textTF = new TextFormat('Verdana', 12, 0x000000);
var tagTF = new TextFormat('Verdana', 12, 0x0000FF);
var tagsAttsTF = new TextFormat('Verdana', 12, 0xFF0000);
var attValuesTF = new TextFormat('Verdana', 12, 0x333333, false);
this.setTextFormat(start, end, textTF);
//loop through the string, and find all tags...
while (myString.indexOf('<', startIndex) != -1 && startIndex', startIndex);
if (endIndex != -1) {
//we have a complete tag...
this.setTextFormat(startIndex-1, endIndex+1, tagTF);
//blue
this.setTextFormat(startIndex, endIndex, tagsAttsTF);
//red
this.setTextFormat(endIndex+2, myString.indexOf('<', endIndex), textTF);
//text bewteen next tags...
//go through and do atts and values...
tagStart = startIndex;
while (myString.indexOf('"', tagStart) != -1 && tagStartthis.prevLength+1 && !Key.isDown(Key.ENTER)) { //code pasted, because this is not an indenting
this.highlightAll();
} else {
this.highlight(startIndex, endIndex);
}
this.prevLength = this.text.length;
};
accord.codePane.codeEdit.label.highlight = function(startIndex, endIndex){
var timer = getTimer();
var tf = this;
var myString = this.text;
var codeLine = myString.substring(startIndex, endIndex);
var commentTF = new TextFormat('Andale Mono', 12, 0x808080, false);
var codeTF = new TextFormat('Andale Mono', 12, 0x000000, false);
var clsTF = new TextFormat('Andale Mono', 12, 0x000066, false);
var strTF = new TextFormat('Andale Mono', 12, 0x009900, false);
var keyTF = new TextFormat('Andale Mono', 12, 0x0000CC, false);
var propTF = new TextFormat('Andale Mono', 12, 0x000084, false);
var numTF = new TextFormat('Andale Mono', 12, 0x990000, false);
var userTF = new TextFormat('Andale Mono', 12, 0x660033, false);
//set default code format
tf.setTextFormat(startIndex, endIndex, codeTF);
//syntax highlighting - find the words in the line...
var st = startIndex;
trace("to start " + st);
var en = endIndex;
var txt = this.text;
var w = "";
while (st<=en) {
var l = txt.substr(st, 1);
if (editor.keywords.seperators[l]) {
//found a seperator - reset the word
w = "";
if (codeLine.lastIndexOf('(') <= codeLine.lastIndexOf(')')){
editor.codeHint.removeMovieClip();
}
} else {
//checking the word w
w += l;
this.setTextFormat(st-(w.length - 1) , st+1, codeTF);
if (keywords.method[w]) {
this.setTextFormat(st-(w.length - 1) , st+1, keyTF);
if (editor.hintCode == true){
showCodeHint(keywords.method[w], startIndex);
}
} else if (keywords.prop[w]) {
this.setTextFormat(st-(w.length - 1) , st+1, propTF);
editor.codeHint.removeMovieClip();
} else if (keywords.cls[w]) {
this.setTextFormat(st-(w.length - 1) , st+1, clsTF);
editor.codeHint.removeMovieClip();
} else if (keywords.special[w]) {
this.setTextFormat(st-(w.length - 1) , st+1, keyTF);
editor.codeHint.removeMovieClip();
} else if (keywords.userDefined[w]) {
this.setTextFormat(st-(w.length - 1) , st+1, userTF);
if (editor.hintCode == true){
showCodeHint(keywords.userDefined[w], startIndex);
}
} else if (!isNaN(w)) {
this.setTextFormat(st-(w.length - 1) , st+1, numTF);
//editor.codeHint.removeMovieClip();
} else {
//editor.codeHint.removeMovieClip();
}
this.setNewTextFormat(codeTF);
}
editor.w = w;
st++;
}
//double quoted strings in code...
var strStart = startIndex;
while (myString.indexOf('"', strStart) != -1 && strStart"] = true;
this.keywords.seperators[">>"] = true;
this.keywords.seperators["~"] = true;
this.keywords.seperators["|"] = true;
this.keywords.seperators["^"] = true;
this.keywords.seperators[">>>"] = true;
this.keywords.seperators["!"] = true;
this.keywords.seperators["&"] = true;
this.keywords.seperators["&&"] = true;
this.keywords.seperators["||"] = true;
this.keywords.seperators["!="] = true;
this.keywords.seperators[">="] = true;
this.keywords.seperators["^="] = true;
this.keywords.seperators["|="] = true;
this.keywords.seperators["&="] = true;
this.keywords.seperators["%="] = true;
this.keywords.seperators[">>="] = true;
this.keywords.seperators[">>>="] = true;
this.keywords.seperators["<="] = true;
this.keywords.seperators["--"] = true;
this.keywords.seperators["++"] = true;
this.keywords.seperators["%"] = true;
this.keywords.seperators["?"] = true;
this.keywords.seperators["-="] = true;
this.keywords.seperators["+="] = true;
this.keywords.seperators["="] = true;
this.keywords.seperators["=="] = true;
this.keywords.seperators["==="] = true;
this.keywords.seperators["!=="] = true;
keywords.cls = new Object();
keywords.cls["Accessibility"] = true;
keywords.cls["Array"] = true;
keywords.cls["Boolean"] = true;
keywords.cls["Button"] = true;
keywords.cls["Color"] = true;
keywords.cls["Date"] = true;
keywords.cls["ExternalInterface"] = true;
keywords.cls["Key"] = true;
keywords.cls["Math"] = true;
keywords.cls["Mouse"] = true;
keywords.cls["MovieClip"] = true;
keywords.cls["Number"] = true;
keywords.cls["Object"] = true;
keywords.cls["PrintJob"] = true;
keywords.cls["Selection"] = true;
keywords.cls["SharedObject"] = true;
keywords.cls["Sound"] = true;
keywords.cls["Stage"] = true;
keywords.cls["String"] = true;
keywords.cls["System"] = true;
keywords.cls["TextField"] = true;
keywords.cls["TextFormat"] = true;
keywords.cls["XML"] = true;
keywords.cls["XMLSocket"] = true;
keywords.cls["RegExp"] = true;
keywords.userDefined = new Object();
keywords.addWord = function(word, defn){
keywords.userDefined[word] = defn;
}
keywords.updateKeyword = function(word, desc){
keywords.userDefined[word] = desc;
contentXML.firstChild.lastChild.attributes[word] = desc;
}
keywords.removeKeyword = function(word){
delete keywords.userDefined[word];
delete contentXML.firstChild.lastChild.attributes[word];
}
keywords.clear = function(){
keywords.userDefined = new Object();
}
keywords.onKeyDown = function(){
if (Key.isDown(117)){
var caret = Selection.getBeginIndex();
accord.codePane.codeEdit.label.highlight(0, caret - 1);
var desc = mdm.Dialogs.inputBox("Enter Description: " + editor.w, "Enter description here");
if (desc != false){
//add the word to the objects
this.addWord(editor.w, desc);
//add it to the VAR icon
contentXML.firstChild.lastChild.attributes[editor.w] = desc;
accord.codePane.codeEdit.label.highlightAll();
Selection.setFocus(accord.codePane.codeEdit.label);
Selection.setSelection(caret,caret);
accord.codePane.codeEdit.label.setNewTextFormat(new TextFormat('Andale Mono', 12, 0x000000, false));
}
}
}
Key.addListener(keywords);
this.keywords.method = new Object();
keywords.method = new Object();
keywords.method["abs"] = 'Math.abs(number)';
keywords.method["acos"] = 'Math.acos(number)';
keywords.method["asin"] = 'Math.asin(number)';
keywords.method["atan"] = 'Math.atan(number)';
keywords.method["atan2"] ='Math.atan2(y,x)';
keywords.method["isNaN"] = 'isNaN()';
keywords.method["ceil"] = 'Math.ceil(number)';
keywords.method["addListener"] = 'Object.addListener(listener)';
keywords.method["addProperty"] = 'Object.addProperty(prop,getter,setter)';
keywords.method["appendChild"] = 'XML.appendChild(childNode)';
keywords.method["asfunction"] = true;
keywords.method["attachMovie"] = 'MovieClip.attachMovie(idName,newName,depth)'
keywords.method["attachSound"] = 'MovieClip.attachSound(idName)';
keywords.method["beginFill"] = 'MovieClip.beginFill(rgb,alpha)';
keywords.method["beginGradientFill"] = 'MovieClip.beginGradientFill((fillType,colors,alphas,ratios,matrix)';
keywords.method["break"] = true;
keywords.method["broadcastMessage"] = '(message, [eventObject])';
keywords.method["call"] = 'myFunction.call(thisObject,param1,...,paramNtrue)';
keywords.method["case"] = true;
keywords.method["charAt"] = 'String.charAt(index)';
keywords.method["charCodeAt"] = 'String.charCodeAt(index)';
keywords.method["clear"] = 'MovieClip.clear()';
keywords.method["clearInterval"] = 'clearInterval(id)';
keywords.method["cloneNode"] = 'XMLNode.cloneNode(deep)';
keywords.method["close"] = true;
keywords.method["concat"] = true;
keywords.method["continue"] = true;
keywords.method["connect"] = true;
keywords.method["cos"] = 'Math.cos(number)';
keywords.method["createElement"] = 'XML.createElement(elementName)';
keywords.method["createEmptyMovieClip"] = 'MovieClip.createEmptyMovieClip(instanceName,depth)';
keywords.method["createTextField"] = 'MovieClip.createTextField(instanceName,depth,x,y,w,h)';
keywords.method["createTextNode"] = 'XML.createTextNode(text)';
keywords.method["curveTo"] = 'MovieClip.curveTo(controlX,controlY,anchorX,anchorY)';
keywords.method["duplicateMovieClip"] = 'MovieClip.duplicateMovieClip(newName,depth[,initObject])';
keywords.method["endFill"] = 'MovieClip.endFill()';
keywords.method["escape"] = true;
keywords.method["eval"] = 'eval(variable)';
keywords.method["exp"] = 'Math.exp(number)';
keywords.method["fromCharCode"] = 'String.fromCharCode(num1,...,numN)';
keywords.method["fscommand"] = 'fscommand(cmd, parameters)';
keywords.method["get"] = 'Camera.get()';
keywords.method["getAscii"] = 'Key.getAscii()';
keywords.method["getBeginIndex"] = 'Selection.getBeginIndex()'
keywords.method["getBounds"] = 'MovieClip.getBounds(targetCoordinateSpace)';
keywords.method["getBytesLoaded"] = 'MovieClip.getBytesLoaded()';
keywords.method["getBytesTotal"] = 'MovieClip.getBytesTotal()';
keywords.method["getCaretIndex"] = 'Selection.getCaretIndex()';
keywords.method["getCode"] = 'Key.getCode()';
keywords.method["getDate"] = 'Date.getDate()';
keywords.method["getDay"] = 'Date.getDay()';
keywords.method["getDepth"] = 'MovieClip.getDepth()';
keywords.method["getEndIndex"] = 'Selection.getEndIndex()';
keywords.method["getFocus"] = 'Component.getFocus()';
keywords.method["getFontList"] = 'TextField.getFontList()';
keywords.method["getFullYear"] = 'Date.getFullYear()';
keywords.method["getHours"] = 'Date.getHours()';
keywords.method["getMilliseconds"] = 'Date.getMilliseconds()';
keywords.method["getMinutes"] = 'Date.getMinutes()';
keywords.method["getMonth"] = 'Date.getMonth()';
keywords.method["getNewTextFormat"] = 'TextField.getNewTextFormat()';
keywords.method["getPan"] = 'Sound.getPan()';
keywords.method["getProperty"] = true;
keywords.method["getRGB"] = 'Color.getRGB()';
keywords.method["getSeconds"] = 'Date.getSeconds()';
keywords.method["getTextExtent"] = 'TextFormat.getTextExtent(text[,wrapWidth])';
keywords.method["getTextFormat"] = 'TextField.getTextFormat(beginIndex,endIndex)';
keywords.method["getTime"] = 'Date.getTime()';
keywords.method["getTimer"] = 'getTimer()';
keywords.method["getTimezoneOffset"] = 'Date.getTimezoneOffset()';
keywords.method["getTransform"] = 'Sound.getTransform()';
keywords.method["getURL"] = 'MovieClip.getURL(url,window,method)';
keywords.method["getUTCDate"] = 'Date.getUTCDate()';
keywords.method["getUTCDay"] = 'Date.getUTCDay()';
keywords.method["getUTCFullYear"] = 'Date.getUTCFullYear()';
keywords.method["getUTCHours"] = 'Date.getUTCHours()';
keywords.method["getUTCMilliseconds"] = 'Date.getUTCMilliseconds()';
keywords.method["getUTCMinutes"] = 'Date.getUTCMinutes()';
keywords.method["getUTCMonth"] = 'Date.getUTCMonth()';
keywords.method["getUTCSeconds"] = 'Date.getUTCSeconds()';
keywords.method["getVersion"] = 'getVersion()';
keywords.method["getVolume"] = 'Sound.getVolume()';
keywords.method["getYear"] = 'Date.getYear()';
keywords.method["globalToLocal"] = 'MovieClip.globalToLocal(point)';
keywords.method["gotoAndPlay"] = 'MovieClip.gotoAndPlay(frame)';
keywords.method["gotoAndStop"] = 'MovieClip.gotoAndStop(frame)';;
keywords.method["hasAccessibility"] = true;
keywords.method["hasAudio"] = true;
keywords.method["hasAudioEncoder"] = true;
keywords.method["hasChildNodes"] = true;
keywords.method["hasMP3"] = true;
keywords.method["hasVideoEncoder"] = true;
keywords.method["height"] = true;
keywords.method["hide"] = 'Mouse.hide()';
keywords.method["hitArea"] = true;
keywords.method["hitTest"] = 'MovieClip.hitTest(x,y,shapeFlag)';
keywords.method["indexOf"] = 'String.indexOf(searchString,fromIndex)';
keywords.method["insertBefore"] = 'XMLNode.insertBefore(newChild,beforeChild)';
keywords.method["install"] = true;
keywords.method["join"] = 'Array.join(sepperator)';
keywords.method["lineStyle"] = 'MovieClip.lineStyle(thickness,rgb,alpha)';
keywords.method["lineTo"] = 'MovieClip.lineTo(x,y)';
keywords.method["lastIndexOf"] = 'String.lastIndexOf(searchString,fromIndex)';
keywords.method["load"] = 'TextField.Stylesheet.load(url)';
keywords.method["loadMovie"] = 'MovieClip.loadMovie(url,method)';
keywords.method["loadMovieNum"] = 'MovieClip.loadMovieNum(url,level,method)';
keywords.method["loadScrollContent"] = true;
keywords.method["loadSound"] = 'Sound.loadSound(url,isStreaming)';
keywords.method["loadVariables"] = 'MovieClip.loadVariables(url,method)';
keywords.method["loadVariablesNum"] = 'loadVariablesNum(url,level[,variables])';
keywords.method["LoadVars"] = true;
keywords.method["log"] = 'Math.log(number)';
keywords.method["max"] = 'Math.max(x,y)';
keywords.method["min"] = 'Math.min(x,y)';
keywords.method["nextFrame"] = 'MovieClip.nextFrame()';
keywords.method["nextScene"] = 'nextScene()';
keywords.method["nextSibling"] = true;
keywords.method["on"] = true;
keywords.method["onChanged"] = true;
keywords.method["onClipEvent"] = true;
keywords.method["onClose"] = true;
keywords.method["onConnect"] = true;
keywords.method["onData"] = true;
keywords.method["onDragOut"] = true;
keywords.method["onDragOver"] = true;
keywords.method["onEnterFrame"] = true;
keywords.method["onKeyDown"] = true;
keywords.method["onKeyUp"] = true;
keywords.method["onKillFocus"] = true;
keywords.method["onLoad"] = true;
keywords.method["onMouseDown"] = true;
keywords.method["onMouseMove"] = true;
keywords.method["onMouseUp"] = true;
keywords.method["onPress"] = true;
keywords.method["onRelease"] = true;
keywords.method["onReleaseOutside"] = true;
keywords.method["onResize"] = true;
keywords.method["onRollOut"] = true;
keywords.method["onRollOver"] = true;
keywords.method["onScroller"] = true;
keywords.method["onSetFocus"] = true;
keywords.method["onSort"] = true;
keywords.method["onSoundComplete"] = true;
keywords.method["onUnload"] = true;
keywords.method["onUpdate"] = true;
keywords.method["onXML"] = true;
keywords.method["parseFloat"] = 'parseFloat(string)';
keywords.method["parseInt"] = 'parseInt(string)';
keywords.method["parseXML"] = 'XML.parseXML(string)';
keywords.method["play"] = 'MediaID.play()';
keywords.method["pop"] = 'Array.pop()';
keywords.method["pow"] = 'Math.pow(x,y)';
keywords.method["push"] = 'Array.push(value)';
keywords.method["prevScene"] = 'prevScene()';
keywords.method["prevFrame"] = 'MovieClip.prevFrame()';
keywords.method["print"] = 'print(target,type)';
keywords.method["printAsBitmap"] = 'printAsBitmap(target,type)';
keywords.method["printAsBitmapNum"] = 'printAsBitmapNum(target,type)';
keywords.method["printNum"] = 'printNum(level,type)';
keywords.method["registerClass"] = 'Object.registerClass(symbolID,theClass)';
keywords.method["removeMovieClip"] = 'MovieClip.removeMovieClip()';
keywords.method["removeNode"] = 'XML.removeNode()';
keywords.method["removeTextField"] = 'TextField.removeTextField()';
keywords.method["replaceSel"] = 'TextField.replaceSel(text)';
keywords.method["reverse"] = 'Array.reverse()';
keywords.method["setDate"] = 'Date.setDate(date)';
keywords.method["setFocus"] = 'Component.setFocus()';
keywords.method["setFullYear"] = 'Date.setFullYear(year,month,date)';
keywords.method["setHours"] = 'Date.setHours(hours,mins,secs,ms)';
keywords.method["setInterval"] = 'setInterval(functionName,interval,params)';
keywords.method["setMask"] = 'MovieClip.setMask(maskClip)';
keywords.method["setMilliseconds"] = 'Date.setMilliseconds(ms)';
keywords.method["setMinutes"] = 'Date.setMinutes(minutes,seconds,ms)';
keywords.method["setMonth"] = 'Date.setMonth(month,date)';
keywords.method["setNewTextFormat"] = 'TextField.setNewTextFormat(textFormat)';
keywords.method["setPan"] = 'Sound.setPan(pan)';
keywords.method["setProperty"] = 'setProperty(target,property,value)';
keywords.method["setRGB"] = 'Color.setRGB(0xRRGGBB)';
keywords.method["setSeconds"] = 'Date.setSeconds(seconds,ms)';
keywords.method["setSelection"] = 'Selection.setSelection(beginIndex,endIndex)';
keywords.method["setTextFormat"] = 'TextFIeld.setTextFormat(textFormat)';
keywords.method["setTime"] = 'Date.setTime(value)';
keywords.method["setTransform"] = 'Sound.setTransform(sxform)';
keywords.method["setUTCDate"] = 'Date.setUTCDate(date)';
keywords.method["setUTCFullYear"] = 'Date.setUTCFullYear(year,month,date)';
keywords.method["setUTCHours"] = 'Date.setUTCHours(hours,mins,secs,ms)';
keywords.method["setUTCMilliseconds"] = 'Date.setUTCMilliseconds(ms)';
keywords.method["setUTCMinutes"] = 'Date.setUTCMinutes(minutes.seconds,ms)';
keywords.method["setUTCMonth"] = 'Date.setUTCMonth(month,date)';
keywords.method["setUTCSeconds"] = 'Date.setUTCSeconds(seconds,ms)';
keywords.method["setVolume"] = 'Sound.setVolume(volume)';
keywords.method["setYear"] = 'Date.setYear(year,month,date)';
keywords.method["send"] = 'XML.send(url,[window])';
keywords.method["sendAndLoad"] = 'IconID.sendAndLoad(reqXML, url)';
keywords.method["loadVars"] = 'IconID.loadVars(url)';
keywords.method["sendAndLoadVars"] = 'IconID.loadVars(url, loadVarsObj)';
keywords.method["set"] = true;
keywords.method["shift"] = 'Array.shift()';
keywords.method["show"] = 'Mouse.show()';
keywords.method["sin"] = 'Math.sin(number)';
keywords.method["slice"] = 'Array.slice(startIndex,endIndex)';
keywords.method["sort"] = 'Array.sort(compareFunction)';
keywords.method["splice"] = 'Array.splice(start,count,elem1, ..., elemN)';
keywords.method["split"] = 'String.split(seperator)';
keywords.method["sqrt"] = 'Math.sqrt(number)';
keywords.method["start"] = 'Sound.start(offset,loops)';
keywords.method["sortOn"] = 'Array.sortOn(key)';
keywords.method["startDrag"] = 'MovieClip.startDrag(lockCentre,left,top,right,bottom)';
keywords.method["stop"] = true;
keywords.method["stopAllSounds"] = 'stopAllSounds()';
keywords.method["stopDrag"] = 'MovieClip.stopDrag()';
keywords.method["substr"] = 'String.substr(index,length)';
keywords.method["substring"] = 'String.substring(indexA,indexB)';
keywords.method["swapDepths"] = 'MovieClip.swapDepths(target)';
keywords.method["tan"] = 'Math.tan(number)';
keywords.method["toggleHighQuality"] = 'toggleHighQuality()';
keywords.method["toLowerCase"] = 'String.toLowerCase()';
keywords.method["toString"] = 'Array.toString()';
keywords.method["toUpperCase"] = 'String.toUpperCase()';
keywords.method["trace"] = true
keywords.method["unescape"] = 'unescape(string)';
keywords.method["uninstall"] = true;
keywords.method["unloadMovie"] = 'unloadMovie(target)';
keywords.method["unloadMovieNum"] = 'unloadMovieNum(level)';
keywords.method["unshift"] = 'Array.unshift(value)';
keywords.method["unwatch"] = 'Object.unwatch(prop)';
keywords.method["updateAfterEvent"] = 'updateAfterEvent()';
keywords.method["watch"] = 'Object.watch(prop,callback,userData)';
keywords.method["instanceof"] = true
keywords.method["int"] = true;
keywords.method["round"] = 'Math.round(number)';
keywords.method["floor"] = 'Math.floor(number)';
keywords.method["moveTo"] = 'MovieClip.moveTo(x,y)';
//component methods / styles
keywords.method["addItem"] = true;
keywords.method["addItemAt"] = true;
keywords.method["applyChanges"] = true;
keywords.method["arrow"] = true;
keywords.method["backgroundDisabled"] = true;
keywords.method["check"] = true;
keywords.method["darkshadow"] = true;
keywords.method["face"] = true;
keywords.method["FCheckBox"] = true;
keywords.method["FComboBox"] = true;
keywords.method["FListBox"] = true;
keywords.method["focusRectInner"] = true;
keywords.method["focusRectOuter"] = true;
keywords.method["foregroundDisabled"] = true;
keywords.method["getData"] = true;
keywords.method["getEnabled"] = true;
keywords.method["getGroupName"] = true;
keywords.method["getItemAt"] = true;
keywords.method["getLabel"] = true;
keywords.method["getLength"] = true;
keywords.method["getPaneHeight"] = true;
keywords.method["getPaneWidth"] = true;
keywords.method["getRowCount"] = true;
keywords.method["getScrollContent"] = true;
keywords.method["getScrollPosition"] = true;
keywords.method["getSelectedIndex"] = true;
keywords.method["getSelectedIndices"] = true;
keywords.method["getSelectedItem"] = true;
keywords.method["getSelectedItems"] = true;
keywords.method["getSelectMultiple"] = true;
keywords.method["getState"] = true;
keywords.method["getValue"] = true;
keywords.method["globalStyleFormat"] = true;
keywords.method["highlight"] = true;
keywords.method["highlight3D"] = true;
keywords.method["loadScrollContent"] = true;
keywords.method["radioDot"] = true;
keywords.method["refreshPane"] = true;
keywords.method["registerSkinElement"] = true;
keywords.method["removeAll"] = true;
keywords.method["removeitemAt"] = true;
keywords.method["removeListener"] = true;
keywords.method["replaceItemAt"] = true;
keywords.method["ScrollTrack"] = true;
keywords.method["selection"] = true;
keywords.method["selectionDisabled"] = true;
keywords.method["selectionUnfocused"] = true;
keywords.method["setAutoHideScrollBar"] = true;
keywords.method["setChangeHandler"] = true;
keywords.method["setClickHandler"] = true;
keywords.method["setData"] = true;
keywords.method["setDataProvider"] = true;
keywords.method["setDragContent"] = true;
keywords.method["setEditable"] = true;
keywords.method["setEnabled"] = true;
keywords.method["setGroupName"] = true;
keywords.method["setHorizontal"] = true;
keywords.method["setHScroll"] = true;
keywords.method["setItemSymbol"] = true;
keywords.method["setLabel"] = true;
keywords.method["setLabelPlacement"] = true;
keywords.method["setLargeScroll"] = true;
keywords.method["setRowCount"] = true;
keywords.method["setScrollContent"] = true;
keywords.method["setScrollPosition"] = true;
keywords.method["setScrollProperties"] = true;
keywords.method["setScrollTarget"] = true;
keywords.method["setSelectedIndex"] = true;
keywords.method["setSelectedIndices"] = true;
keywords.method["setSelectionIndex"] = true;
keywords.method["setSelectMultiple"] = true;
keywords.method["setSize"] = true;
keywords.method["setSmallScroll"] = true;
keywords.method["setState"] = true;
keywords.method["setStyleProperty"] = true;
keywords.method["setValue"] = true;
keywords.method["setVScroll"] = true;
keywords.method["setWidth"] = true;
keywords.method["shadow"] = true;
keywords.method["sortItemsBy"] = true;
keywords.method["textAlign"] = true;
keywords.method["textBold"] = true;
keywords.method["textColor"] = true;
keywords.method["textDisabled"] = true;
keywords.method["textFont"] = true;
keywords.method["textIndent"] = true;
keywords.method["textItalic"] = true;
keywords.method["textLeftMargin"] = true;
keywords.method["textRightMargin"] = true;
keywords.method["textSelected"] = true;
keywords.method["textSize"] = true;
keywords.method["textUnderline"] = true;
//engine specific methods here...
keywords.method["debug"] = 'debug(message)';
keywords.method["contains"] = 'Array.contains(item)';
keywords.method["findValue"] = 'Array.findValue(item)';
keywords.method["randomize"] = 'Array.randomize()';
keywords.method["sum"] = 'Array.sum()';
keywords.method["sumTo"] = 'Array.sumTo(index)';;
keywords.method["clip"] = 'XMLNode.clip()';
keywords.method["getMovieClip"] = 'XMLNode.getMovieClip()';
keywords.method["getLoadedMovie"] = 'IconID.getLoadedMovie()';
keywords.method["index"] = 'XMLNode.index()';
keywords.method["drawBorder"] = 'IconID.drawBorder(width,colour,alpha)'
keywords.method["fillIcon"] = 'IconID.fillIcon(color,alpha)';
keywords.method["display"] = 'IconID.display()';
keywords.method["erase"] = 'IconID.erase()';
keywords.method["remove"] = 'IconID.remove()';
keywords.method["animate"] = "IconID.animate(x,y,speed,style)";
keywords.method["tween"] = "IconID.tween(property,begin,end,duration,easing,easeType)";
keywords.method["setRotation"] = 'IconID.setRotation(degrees)';
keywords.method["rotateTo"] = 'IconID.rotateTo(degrees,step,clockwise)';
keywords.method["fadeTo"] = 'IconID.fadeTo(alpha,step)';
keywords.method["setScale"] = 'IconID.setScale(percent)';
keywords.method["loadXML"] = 'IconID.loadXML(url)';
keywords.method["loadLibrary"] = 'rootIcon.loadLibrary(url)';
keywords.method["broadcast"] = 'IconID.broadcast(eventName, [evtObject])';
keywords.method["addEventListener"] = 'IconID.addEventListener(object)';
keywords.method["removeEventListener"] = 'IconID.removeEventListener(object)';
keywords.method["setStatusText"] = 'rootIcon.setStatusText(string)';
keywords.method["enableControls"] = 'rootIcon.enableControls(boolean)';;
keywords.method["showNext"] = 'rootIcon.showNext()';
keywords.method["slideNext"] = 'rootIcon.slideNext()';
keywords.method["hideNext"] = 'rootIcon.hideNext()';
keywords.method["showTOC"] = 'rootIcon.showTOC()';
keywords.method["showHelp"] = 'rootIcon.showHelp()';
keywords.method["setText"] = 'IconID.setText(htmlText)';
keywords.method["appendText"] = 'IconID.appendText(htmlText)';
keywords.method["setGutter"] = 'IconID.setGutter(pixels)';
keywords.method["enableScroll"] = true;
keywords.method["hideGlossary"] = true;
keywords.method["judge"] = 'InteractionID.judge()';
keywords.method["exit"] = 'parentID.exit()';
keywords.method["reset"] = 'MediaID.reset();'
keywords.method["nextPage"] = 'FrameworkID.nextPage()';
keywords.method["prevPage"] = 'FrameworkID.prevPage()';
keywords.method["gotoPage"] = 'FrameworkID.gotoPage()';
keywords.method["lastPage"] = 'FrameworkID.lastPage()';
keywords.method["firstPage"] = 'FrameworkID.firstPage()';
keywords.method["setHelpText"] = 'PageID.setHelpText(string)';
keywords.method["dashTo"] = 'MovieClip.dashTo(startx,starty,endx,endy,len,gap)';
keywords.method["arrowTo"] = 'MovieClip.arrowTo(startx,starty,endx,endy,[size,spread])';
keywords.method["drawRect"] = 'MovieClip.drawRect(x,y,w,h[,cornerRadius])';
keywords.method["drawSunkenRect"] = 'MovieClip.drawSunkenRect(x,y,w,h)';
keywords.method["drawPoly"] = 'MovieClip.drawPoly(x,y,sides,radius,angle)';
keywords.method["drawOval"] ='MovieClip.drawOval(x,y,radius,yRadius)';
keywords.method["drawArc"] = 'MovieClip.drawArc(x,y,radius,arc,startAngle,yRadius)';
keywords.method["drawWedge"] = 'MovieClip.drawWedge(x,y,startAngle,arc,radius,yRadius)';
keywords.method["drawGear"] = 'MovieClip.drawGear(x,y,sides,innerRadius,outerRadius,angle,holeSides,holeRadius)';
keywords.method["drawStar"] = 'MovieClip.drawStar(x,y,points,innerRadius,outerRadius,angle)';
keywords.method["drawBurst"] = 'MovieClip.drawBurst(x,y,sides,innerRadius,outerRadius,angle)';
keywords.method["addTerm"] = 'Glossary.addTerm(term,defn)';
keywords.method["getKOData"] = 'getKOData()';
keywords.method["scaleTo"] = 'Icon.scaleTo(percent,step)';
keywords.method["replace"] = 'replace(stringObject,searchFor,replaceWith)';
keywords.method["duplicate"] = 'XMLNode.duplicate([count], [initObject])';
keywords.method["reset"] = 'MediaID.reset()';
keywords.method["enableTTS"] = 'enableTTS()';
keywords.method["speak"] = 'speak(text)';
keywords.method["inspect"] = 'inspect(object [,deep])';
keywords.method["dropShadow"] = 'MovieClip.dropShadow(distance,angle,colour,alpha)';
keywords.method["glow"] = 'MovieClip.glow(colour,alpha,blurX,blurY)';
keywords.method["bevel"] = 'MovieClip.bevel(distance,angle,highlightColour,shadowColour)';
keywords.method["clearFilters"] = 'MovieClip.clearFilters()';
keywords.method["showAnswers"] = 'IconID.showAnswers(colour)';
keywords.method["hideAnswers"] = 'IconID.hideAnswers()';
keywords.method["getPageIndex"] = 'XMLNode.getPageIndex()';
keywords.method["getChildByName"] = 'XMLNode.getChildByName(name)';
keywords.method["getChildByID"] = 'XMLNode.getChildByID(id)';
keywords.method["findParentByType"] = 'XMLNode.findParentByType(type)';
keywords.method["findParentByName"] = 'XMLNode.findParentByName(name)';
keywords.method["findParentByID"] = 'XMLNode.findParentByID(ID)';
keywords.method["makeBG"] = 'IconID.makeBG(colour, alpha, leftRight,angle)';
keywords.method["setChecked"] = 'rs.setChecked(check,uncheckOthers)';
keywords.method["breakApart"] = 'IconID.breakApart(xSpace,ySpace,handCursor,dragDrop)';
keywords.method["setContentPath"] = 'IconID.setContentPath(url)';
keywords.method["getText"] = 'IconID.getText()';
keywords.method["loadCSS"] = 'IconID.loadCSS(url)';
keywords.method["colourText"] = 'IconID.colourText("#RRGGBB")';
keywords.method["duplicateIcon"] = 'IconID.duplicateIcon([dragDrop,x1,y1,x2,y2])';
keywords.method["hideControls"] = 'rootIcon.hideControls()';
keywords.method["hideInfo"] = 'rootIcon.hideInfo()';
keywords.method["printScreen"] = 'rootIcon.printScreen()';
keywords.method["loadImage"] = 'IconID.loadImage(url)';
keywords.method["snapToGrid"] = 'IconID.snapToGrid(xWidth,yWidth,gridStartX,gridStartY)';
keywords.method["addDraw"] = 'IconID.addDraw(x,y,w,h,fill)';
keywords.method["addColourPicker"] = 'IconID.addColourPicker(x,y)';
keywords.method["loadIcon"] = 'rootIcon.loadIcon(url)';
keywords.method["hideLogo"] = 'rootIcon.hideLogo()';
keywords.method["showTip"] = 'IconID.hideTip()';
keywords.method["hideTip"] = 'IconID.showTip()';
keywords.method["levenshtein"] = 'String.levenshtein(targetString)';
keywords.method["setCustomCursor"] = 'IconID.setCustomCursor()';
keywords.method["hideCustomCursor"] = 'IconID.hideCustomCursor()';
keywords.method["findChildNodes"] = 'XMLNode.findChildNodes(attName, attValue)';
keywords.method["toObject"] = 'XML.toObject()';
keywords.method["makeDraggable"] = 'IconID.makeDraggable(bool,x,y,w,h)';
keywords.method["allowKeyControl"] = 'IconID.allowKeyControl(x,y,w,h)';
keywords.method["getTextWidth"] = 'IconID.getTextWidth()';
keywords.method["getTemplateFolder"] = 'IconID.getTemplateFolder()';
keywords.method["drawPanel"] = 'IconID.drawPanel(x,y,w,h,colour,title,drag)';
keywords.method["fade"] = "IconID.fade(dir, duration, easing, easeType)";
keywords.method["zoom"] = "IconID.zoom(dir, duration, easing, easeType)";
keywords.method["wipe"] = "IconID.wipe(dir, duration, easing, easeType, startPoint)";
keywords.method["fly"] = "IconID.fly(dir, duration, easing, easeType, startPoint)";
keywords.method["squeeze"] = "IconID.squeeze(dir, duration, easing, easeType, dimension)";
keywords.method["iris"] = "IconID.iris(dir, duration, easing, easeType, shape)";
keywords.method["blinds"] = "IconID.blinds(dir, duration, easing, easeType, numStrips, dimension)";
keywords.method["dissolve"] = "IconID.dissolve(dir, duration, easing, easeType, xSections, ySections)";
keywords.method["constrain"] = "IconID.constrain(maxWidth, maxHeight)";
keywords.method["expression"] = "expression(string, contextObject)";
keywords.method["script"] = "script(string, contextObject)";
keywords.number = new Object();
keywords.number["0"] = true;
keywords.number["1"] = true;
keywords.number["2"] = true;
keywords.number["3"] = true;
keywords.number["4"] = true;
keywords.number["5"] = true;
keywords.number["6"] = true;
keywords.number["7"] = true;
keywords.number["8"] = true;
keywords.number["9"] = true;
keywords.prop = new Object();
keywords.prop["_highquality"] = true;
keywords.prop["_currentframe"] = true;
keywords.prop["_droptarget"] = true;
keywords.prop["_focusrect"] = true;
keywords.prop["_framesloaded"] = true;
keywords.prop["_alpha"] = true;
keywords.prop["_height"] = true;
keywords.prop["_name"] = true;
keywords.prop["_quality"] = true;
keywords.prop["_rotation"] = true;
keywords.prop["_soundbuftime"] = true;
keywords.prop["_target"] = true;
keywords.prop["_totalframes"] = true;
keywords.prop["_url"] = true;
keywords.prop["_visible"] = true;
keywords.prop["_width"] = true;
keywords.prop["_x"] = true;
keywords.prop["_xmouse"] = true;
keywords.prop["_xscale"] = true;
keywords.prop["_y"] = true;
keywords.prop["_ymouse"] = true;
keywords.prop["_yscale"] = true;
keywords.prop["align"] = true;
keywords.prop["attributes"] = true;
keywords.prop["autoSize"] = true;
keywords.prop["background"] = true;
keywords.prop["backgroundColor"] = true;
keywords.prop["bold"] = true;
keywords.prop["border"] = true;
keywords.prop["borderColor"] = true;
keywords.prop["bottomScroll"] = true;
keywords.prop["bullet"] = true;
keywords.prop["callee"] = true;
keywords.prop["caller"] = true;
keywords.prop["capabilities"] = true;
keywords.prop["childNodes"] = true;
keywords.prop["color"] = true;
keywords.prop["contentType"] = true;
keywords.prop["docTypeDecl"] = true;
keywords.prop["duration"] = true;
keywords.prop["embedFonts"] = true;
keywords.prop["enabled"] = true;
keywords.prop["firstChild"] = true;
keywords.prop["focusEnabled"] = true;
keywords.prop["foregroundDisabled"] = true;
keywords.prop["hscroll"] = true;
keywords.prop["html"] = true;
keywords.prop["htmlText"] = true;
keywords.prop["indent"] = true;
keywords.prop["ignoreWhite"] = true;
keywords.prop["isActive"] = true;
keywords.prop["isDown"] = true;
keywords.prop["isFinite"] = true;
keywords.prop["isNaN"] = true;
keywords.prop["isToggled"] = true;
keywords.prop["italic"] = true;
keywords.prop["lastChild"] = true;
keywords.prop["leading"] = true;
keywords.prop["leftMargin"] = true;
keywords.prop["length"] = true;
keywords.prop["manufacturer"] = true;
keywords.prop["maxChars"] = true;
keywords.prop["maxhscroll"] = true;
keywords.prop["multiline"] = true;
keywords.prop["nextSibling"] = true;
keywords.prop["nodeName"] = true;
keywords.prop["nodeType"] = true;
keywords.prop["nodeValue"] = true;
keywords.prop["parentNode"] = true;
keywords.prop["pixelAspectRatio"] = true;
keywords.prop["previousSibling"] = true;
keywords.prop["resolutionX"] = true;
keywords.prop["resolutionY"] = true;
keywords.prop["restrict"] = true;
keywords.prop["rightMargin"] = true;
keywords.prop["scaleMode"] = true;
keywords.prop["screenColor"] = true;
keywords.prop["screenDPI"] = true;
keywords.prop["screenResolution"] = true;
keywords.prop["screenResolutionX"] = true;
keywords.prop["screenResolutionY"] = true;
keywords.prop["scroll"] = true;
keywords.prop["selectable"] = true;
keywords.prop["showMenu"] = true;
keywords.prop["size"] = true;
keywords.prop["status"] = true;
keywords.prop["tabChildren"] = true;
keywords.prop["tabEnabled"] = true;
keywords.prop["tabIndex"] = true;
keywords.prop["tabStops"] = true;
keywords.prop["target"] = true;
keywords.prop["targetPath"] = true;
keywords.prop["text"] = true;
keywords.prop["textHeight"] = true;
keywords.prop["textWidth"] = true;
keywords.prop["trackAsMenu"] = true;
keywords.prop["type"] = true;
keywords.prop["typeof"] = true;
keywords.prop["underline"] = true;
keywords.prop["url"] = true;
keywords.prop["useHandCursor"] = true;
keywords.prop["valueOf"] = true;
keywords.prop["variable"] = true;
keywords.prop["version"] = true;
keywords.prop["width"] = true;
keywords.prop["wordWrap"] = true;
keywords.prop["xmlDecl"] = true;
keywords.prop["loaded"] = true;
keywords.prop["os"] = true;
keywords.prop["password"] = true;
keywords.prop["position"] = true;
keywords.prop["font"] = true;
keywords.prop["italic"] = true;
keywords.prop["language"] = true;
keywords.prop["list"] = true;
keywords.prop["or"] = true;
//engine specific properties
keywords.prop["rootIcon"] = true;
keywords.prop["icon"] = true;
keywords.prop["FileLocation"] = true;
keywords.prop["XMLElement"] = true;
keywords.prop["rawText"] = true;
keywords.prop["clip"] = true;
keywords.prop["responses"] = true;
keywords.prop["pages"] = true;
keywords.prop["currentPage"] = true;
keywords.prop["pageCount"] = true;
keywords.prop["repCount"] = true;
keywords.prop["Glossary"] = true;
keywords.prop["wordClicked"] = true;
keywords.prop["objectClicked"] = true;
keywords.prop["objectDropped"] = true;
keywords.prop["blendMode"] = true;
keywords.prop["eventObject"] = true;
keywords.prop["hotTextClicked"] = true;
keywords.special = new Object();
keywords.special["default"] = true;
keywords.special["delete"] = true;
keywords.special["_global"] = true;
keywords.special["_level"] = true;
keywords.special["_parent"] = true;
keywords.special["_root"] = true;
keywords.special["this"] = true;
keywords.special["add"] = true;
keywords.special["and"] = true;
keywords.special["chr"] = true;
keywords.special["eq"] = true;
keywords.special["ge"] = true;
keywords.special["ifFrameLoaded"] = true;
keywords.special["int"] = true;
keywords.special["le"] = true;
keywords.special["maxscroll"] = true;
keywords.special["mbchr"] = true;
keywords.special["mblength"] = true;
keywords.special["mbord"] = true;
keywords.special["mbsubstring"] = true;
keywords.special["not"] = true;
keywords.special["or"] = true;
keywords.special["ord"] = true;
keywords.special["random"] = true;
keywords.special["substring"] = true;
keywords.special["tellTarget"] = true;
keywords.special["toggleHighQuality"] = true;
keywords.special["chr"] = true;
keywords.special["ord"] = true;
keywords.special["not"] = true;
keywords.special["#endinitclip"] = true;
keywords.special["#include"] = true;
keywords.special["#initclip"] = true;
keywords.special["FPushButton"] = true;
keywords.special["FRadioButton"] = true;
keywords.special["FScrollBar"] = true;
keywords.special["FScrollPane"] = true;
keywords.special["FStyleFormat"] = true;
keywords.special["apply"] = true;
keywords.special["arguments"] = true;
keywords.special["constructor"] = true;
keywords.special["do"] = true;
keywords.special["else"] = true;
keywords.special["false"] = true;
keywords.special["for"] = true;
keywords.special["prototype"] = true;
keywords.special["function"] = true;
keywords.special["if"] = true;
keywords.special["in"] = true;
keywords.special["new"] = true;
keywords.special["newline"] = true;
keywords.special["null"] = true;
keywords.special["return"] = true;
keywords.special["super"] = true;
keywords.special["switch"] = true;
keywords.special["true"] = true;
keywords.special["undefined"] = true;
keywords.special["var"] = true;
keywords.special["void"] = true;
keywords.special["while"] = true;
keywords.special["with"] = true;
events.cmd = mdm.cmdparameters("1", "events.cmd");
XMLNode.prototype.index = function() {
for (var i = 0; i0) {
// init vars
var theta, angle, cx, cy, px, py;
// make sure that w + h are larger than 2*cornerRadius
if (cornerRadius>Math.min(w, h)/2) {
cornerRadius = Math.min(w, h)/2;
}
// theta = 45 degrees in radians
theta = Math.PI/4;
// draw top line
this.moveTo(x+cornerRadius, y);
this.lineTo(x+w-cornerRadius, y);
//angle is currently 90 degrees
angle = -Math.PI/2;
// draw tr corner in two parts
cx = x+w-cornerRadius+(Math.cos(angle+(theta/2))*cornerRadius/Math.cos(theta/2));
cy = y+cornerRadius+(Math.sin(angle+(theta/2))*cornerRadius/Math.cos(theta/2));
px = x+w-cornerRadius+(Math.cos(angle+theta)*cornerRadius);
py = y+cornerRadius+(Math.sin(angle+theta)*cornerRadius);
this.curveTo(cx, cy, px, py);
angle += theta;
cx = x+w-cornerRadius+(Math.cos(angle+(theta/2))*cornerRadius/Math.cos(theta/2));
cy = y+cornerRadius+(Math.sin(angle+(theta/2))*cornerRadius/Math.cos(theta/2));
px = x+w-cornerRadius+(Math.cos(angle+theta)*cornerRadius);
py = y+cornerRadius+(Math.sin(angle+theta)*cornerRadius);
this.curveTo(cx, cy, px, py);
// draw right line
this.lineTo(x+w, y+h-cornerRadius);
// draw br corner
angle += theta;
cx = x+w-cornerRadius+(Math.cos(angle+(theta/2))*cornerRadius/Math.cos(theta/2));
cy = y+h-cornerRadius+(Math.sin(angle+(theta/2))*cornerRadius/Math.cos(theta/2));
px = x+w-cornerRadius+(Math.cos(angle+theta)*cornerRadius);
py = y+h-cornerRadius+(Math.sin(angle+theta)*cornerRadius);
this.curveTo(cx, cy, px, py);
angle += theta;
cx = x+w-cornerRadius+(Math.cos(angle+(theta/2))*cornerRadius/Math.cos(theta/2));
cy = y+h-cornerRadius+(Math.sin(angle+(theta/2))*cornerRadius/Math.cos(theta/2));
px = x+w-cornerRadius+(Math.cos(angle+theta)*cornerRadius);
py = y+h-cornerRadius+(Math.sin(angle+theta)*cornerRadius);
this.curveTo(cx, cy, px, py);
// draw bottom line
this.lineTo(x+cornerRadius, y+h);
// draw bl corner
angle += theta;
cx = x+cornerRadius+(Math.cos(angle+(theta/2))*cornerRadius/Math.cos(theta/2));
cy = y+h-cornerRadius+(Math.sin(angle+(theta/2))*cornerRadius/Math.cos(theta/2));
px = x+cornerRadius+(Math.cos(angle+theta)*cornerRadius);
py = y+h-cornerRadius+(Math.sin(angle+theta)*cornerRadius);
this.curveTo(cx, cy, px, py);
angle += theta;
cx = x+cornerRadius+(Math.cos(angle+(theta/2))*cornerRadius/Math.cos(theta/2));
cy = y+h-cornerRadius+(Math.sin(angle+(theta/2))*cornerRadius/Math.cos(theta/2));
px = x+cornerRadius+(Math.cos(angle+theta)*cornerRadius);
py = y+h-cornerRadius+(Math.sin(angle+theta)*cornerRadius);
this.curveTo(cx, cy, px, py);
// draw left line
this.lineTo(x, y+cornerRadius);
// draw tl corner
angle += theta;
cx = x+cornerRadius+(Math.cos(angle+(theta/2))*cornerRadius/Math.cos(theta/2));
cy = y+cornerRadius+(Math.sin(angle+(theta/2))*cornerRadius/Math.cos(theta/2));
px = x+cornerRadius+(Math.cos(angle+theta)*cornerRadius);
py = y+cornerRadius+(Math.sin(angle+theta)*cornerRadius);
this.curveTo(cx, cy, px, py);
angle += theta;
cx = x+cornerRadius+(Math.cos(angle+(theta/2))*cornerRadius/Math.cos(theta/2));
cy = y+cornerRadius+(Math.sin(angle+(theta/2))*cornerRadius/Math.cos(theta/2));
px = x+cornerRadius+(Math.cos(angle+theta)*cornerRadius);
py = y+cornerRadius+(Math.sin(angle+theta)*cornerRadius);
this.curveTo(cx, cy, px, py);
} else {
// cornerRadius was not defined or = 0. This makes it easy.
this.moveTo(x, y);
this.lineTo(x+w, y);
this.lineTo(x+w, y+h);
this.lineTo(x, y+h);
this.lineTo(x, y);
}
};
//hack to init the preview form
mdm.Forms.preview.show();
mdm.Forms.preview.hide();
mdm.Forms.wizard.show();
mdm.Forms.wizard.hide();
mdm.Forms.flexEdit.show();
mdm.Forms.flexEdit.hide();
mdm.Forms.drawing.show();
mdm.Forms.drawing.hide();
mdm.Forms.debugger.alpha = 0;
mdm.Forms.debugger.show();
mdm.Forms.debugger.hide();
mdm.Forms.debugger.alpha = 255;
tree.setFocus();
//start up tips...
var tipsString = "";
tipsString += "You can hold down SHIFT whilst double clicking an icon in the tree will expand all of that icon's children.;";
tipsString += "You can easily add icons to the icon selected in the document tree by double clicking the icons in the icon palette.;";
tipsString += "You can hold down CONTROL to jump straight to the currently selected icon in the document tree when previewing your work.;";
tipsString += "You can quickly open an .rlo file by dragging the file into the application window.;";
tipsString += "You can move icons around the document tree by dragging and dropping the icons.;";
tipsString += "You can import graphics and sounds by selecting the page you want to add the media to, and dragging the files into the application window.;";
tipsString += "You can import text from text files by selecting the page you want to add the text to, and dragging the text file into the application window.;";
tipsString += "You can resize the panels by dragging the thin panel between the document tree and properties panels.;";
tipsString += "You can quickly create a SCORM compliant content package of the current file by using the 'Package...' option on the File Menu.;";
tipsString += "You can quickly create the files necessary for publishing your file on the web by using the 'Publish...' option on the File Menu.;";
tipsString += "You can re-use code between projects by selecting an icon, and choosing 'Save Model' from the File menu.;";
tipsString += "You can add previously saved models to the current file by choosing 'Insert Model...' from the File menu.;";
tipsString += "You can easily create a new colour scheme for your project by using the 'Colour Scheme' command on the commands menu.;";
tipsString += "You can search through a file by using the 'Find' command on the commands menu.;";
tipsString += "You can extend the functionality of the application by creating custom commands for the Commands menu.;";
tipsString += "You can reduce the ammount of code in your projects by creating functions that carry out repetitive tasks.;";
tipsString += "You can format text using HTML tags in the text pane of the properties panel.;";
tipsString += "You can declare a stylesheet for the learning object on the Learning Object icon that controls all text formatting in your file;";
tipsString += "You can change all the styles for a project by changing the styles properties on the Learning Object icon.;";
tipsString += "You can turn off the default interface for projects by changing the 'visuals' property of the Interface icon to '0'.;";
tipsString += "You can pages to a sound icon and set the synchPoint property of the page to the position (in milliseconds) in the sound when you want the page to display.;";
tipsString += "An .rlo file is saved each time it is previewed.;";
tipsString += "You can jump straight to the currently selected icon in the document tree by holding down CTRL when you press F5 to preview the file.;";
tipsString += "You can add you own items to the tools menu by editing the 'tools.xml' file in the application's installation folder, and placing the corresponding .swf file in the tools folder.;";
tipsString += "You can create components to allow complex content to be easily configured through a wizard.;";
tipsString += "You can use the FLV file format for high quality video.;";
tipsString += "You can use the button templates in the /templates folder to quickly produce custom buttons for your projects;";
tipsString += "You can use the framework templates in the /templates folder to quickly produce custom controllers for frameworks and interfaces in your projects;";
tipsString += "You can use the FLV file format for high quality video.;";
tipsString += "You can hold down the SHIFT key when previewing to edit coordinates and dimensions visually.;";
tipsString += "You can hold down the CONTROL key when creating a new file to create a blank project with no visuals or styles applied.;";
tipsString += "You can hold down the SHIFT key when moving icons in edit mode to constrain movement to the x or y axis.;";
mdm.Application.onSplashClosed = function() {
var showTips = mdm.System.Registry.loadString(2, "Software\\UoN\\Xerte", "tips");
if (showTips == '1') {
var tipsResult = mdm.Application.showTips(tipsString);
if (tipsResult == false) {
//turn off tips
mdm.System.Registry.saveString(2, "Software\\UoN\\Xerte", "tips", "0");
}
}
var usageMode = mdm.System.Registry.loadString(2, "Software\\UoN\\Xerte", "usageMode")
if (usageMode != 'developer'){
runKOWizard();
}
};
mdm.Application.enableExitHandler();
mdm.Application.onFormClose = function(){
if (editor.FileLocation != "" && editor.FileLocation.indexOf('.rla') == -1){
var result = mdm.Dialogs.PromptModal("Do you want to exit Xerte?", "yesno", "confirm");
if (result == true){
var fileSave = mdm.Dialogs.PromptModal("Save file before exit?", "yesno", "confirm");
if (fileSave == true){
saveFile();
}
mdm.Application.exit();
}
} else {
mdm.Application.exit();
}
}
mdm.Application.onFormMinimize = function(){
mdm.Application.minimize();
}
//ICON PALETTE//////////////////////////////////////////////////////////////////
iconPalette.titleBar.onPress = function(){
this._parent.startDrag(false,0,0,800,600);
}
iconPalette.titleBar.onRelease = function(){
this._parent.stopDrag();
}
icTree = iconPalette.iconsTree.getTree();
iconPalette.iconsTree.dragRules = 15;
icTree.labelFunction = function(){
return "";
}
icTree.iconFunction = function(item) {
if (item.nodeName == 'PG') {
return 'icPG';
}
if (item.nodeName == 'DIS') {
return 'icDIS';
}
if (item.nodeName == 'ABC') {
return 'icABC';
}
if (item.nodeName == 'DRW') {
return 'icDRW';
}
if (item.nodeName == 'SND') {
return 'icSND';
}
if (item.nodeName == 'MOV') {
return 'icMOV';
}
if (item.nodeName == 'SCR') {
return 'icSCR';
}
if (item.nodeName == 'COM') {
return 'icCOM';
}
if (item.nodeName == 'FW_ENT') {
return 'icFW_ENT';
}
if (item.nodeName == 'INT') {
return 'icINT';
}
if (item.nodeName == 'FW') {
return 'icFW';
}
if (item.nodeName == 'DEC') {
return 'icDEC';
}
};
icTree.vScrollPolicy = "off";
icTree.setStyle('disclosureClosedIcon', 'icNull');
icTree.setStyle('disclosureOpenIcon', 'icNull');
icTree.setStyle('selectionColor ', 0xFFFFFF);
icTree.setStyle('rollOverColor', 0xFFFFFF);
myList = new Object();
myList.double_click = function(evt:Object){
if (icTree.selectedNode.nodeName == 'ABC'){
if (tree.selectedNode.nodeName == 'PG' || tree.selectedNode.nodeName == 'FW_ENT' || (tree.selectedNode.nodeName == 'RES' && tree.selectedNode.attributes.type != 'label') || tree.selectedNode.nodeName == 'KO'){
addABC();
}
}
if (icTree.selectedNode.nodeName == 'DIS'){
if (tree.selectedNode.nodeName == 'PG' || tree.selectedNode.nodeName == 'FW_ENT' || (tree.selectedNode.nodeName == 'RES' && tree.selectedNode.attributes.type != 'label') || tree.selectedNode.nodeName == 'KO'){
addDis();
}
}
if (icTree.selectedNode.nodeName == 'DRW'){
if (tree.selectedNode.nodeName == 'PG' || tree.selectedNode.nodeName == 'FW_ENT' || (tree.selectedNode.nodeName == 'RES' && tree.selectedNode.attributes.type != 'label') || tree.selectedNode.nodeName == 'KO'){
addDrw();
}
}
if (icTree.selectedNode.nodeName == 'SND'){
if (tree.selectedNode.nodeName == 'PG' || tree.selectedNode.nodeName == 'FW_ENT' || (tree.selectedNode.nodeName == 'RES' && tree.selectedNode.attributes.type != 'label') || tree.selectedNode.nodeName == 'KO'){
addSnd();
}
}
if (icTree.selectedNode.nodeName == 'MOV'){
if (tree.selectedNode.nodeName == 'PG' || tree.selectedNode.nodeName == 'FW_ENT' || (tree.selectedNode.nodeName == 'RES' && tree.selectedNode.attributes.type != 'label') || tree.selectedNode.nodeName == 'KO'){
addMov();
}
}
if (icTree.selectedNode.nodeName == 'SCR'){
if (tree.selectedNode.nodeName == 'PG' || tree.selectedNode.nodeName == 'FW_ENT' || (tree.selectedNode.nodeName == 'RES' && tree.selectedNode.attributes.type != 'label') || tree.selectedNode.nodeName == 'KO'){
addScr();
}
}
if (icTree.selectedNode.nodeName == 'PG'){
if (tree.selectedNode.nodeName == 'FW' || tree.selectedNode.nodeName == 'DEC' || tree.selectedNode.nodeName == 'IFC' || tree.selectedNode.nodeName == 'SND'){
addPg();
}
if (tree.selectedNode.nodeName == 'INT'){
respTypes._visible = true;
respTypes.init(tree.selectedItem, tree.selectedItem.childNodes.length);
respTypes._x = iconPalette._x + iconPalette._width - 2;
respTypes._y = iconPalette._y + 92;
}
}
if (icTree.selectedNode.nodeName == 'FW'){
if (tree.selectedNode.nodeName == 'PG' || tree.selectedNode.nodeName == 'FW_ENT' || (tree.selectedNode.nodeName == 'RES' && tree.selectedNode.attributes.type != 'label') || tree.selectedNode.nodeName == 'KO'){
addFW();
}
}
if (icTree.selectedNode.nodeName == 'FW_ENT'){
if (tree.selectedNode.nodeName == 'FW' || tree.selectedNode.nodeName == 'IFC'){
addFwEnt();
}
}
if (icTree.selectedNode.nodeName == 'INT'){
if (tree.selectedNode.nodeName == 'PG' || tree.selectedNode.nodeName == 'FW_ENT' || (tree.selectedNode.nodeName == 'RES' && tree.selectedNode.attributes.type != 'label') || tree.selectedNode.nodeName == 'KO'){
addInt();
}
}
if (icTree.selectedNode.nodeName == 'DEC'){
if (tree.selectedNode.nodeName == 'PG' || tree.selectedNode.nodeName == 'FW_ENT' || (tree.selectedNode.nodeName == 'RES' && tree.selectedNode.attributes.type != 'label') || tree.selectedNode.nodeName == 'KO'){
addDec();
}
}
}
myList.itemRollOver = function(evt){
tipIntID = setInterval(showTip, 500, evt.target.getItemAt(evt.index));
}
myList.itemRollOut = function(evt){
editor.tooltip.removeMovieClip();
clearInterval(tipIntID);
}
showTip = function(node){
editor.attachMovie('tooltip', 'tooltip', this.getNextHighestDepth());
editor.tooltip._x = _xmouse;
editor.tooltip._y = _ymouse - 16;
var txtFmt = new TextFormat('Verdana', 10);
var width = txtFmt.getTextExtent(node.attributes.tip).width;
editor.tooltip.beginFill(0xFFFF99,100);
editor.tooltip.lineStyle(0,0x666666,100)
editor.tooltip.drawRect(0,0,width + 8,16);
editor.tooltip.tiptext.text = node.attributes.tip
clearInterval(tipIntID);
}
iconPalette.iconsTree.addEventListener('double_click', myList);
icTree.addEventListener('itemRollOver', myList);
icTree.addEventListener('itemRollOut', myList);
//allow drag and drop between th icon palette and the tree view...
dragCtrl.addReference(icTree, tree);//, DragController.DENYDROPINBETWEEN);
dragCtrlList = new Object();
dragCtrlList.dragStart = function(evt){
//editor.attachMovie('ic'+ evt.sourceItem.nodeName, 'dragMouse', 500);
Mouse.addListener(mouseList);
}
mouseList = new Object()
mouseList.onMouseMove = function(){
//editor.dragMouse._x = _xmouse - 8; //+ 9;
//editor.dragMouse._y = _ymouse - 8 ;//+ 12;
}
dragCtrlList.dragComplete = function(evt){
evt.skip();
dragMouse.removeMovieClip();
Mouse.removeListener(mouseList);
if (evt.sourceItem.nodeName == 'ABC'){
if (evt.targetItem.nodeName == 'PG' || evt.targetItem.nodeName == 'FW_ENT' || (evt.targetItem.nodeName == 'RES' && evt.targetItem.attributes.type != 'label') || evt.targetItem.nodeName == 'KO'){
evt.targetItem.insertBefore(new XML('').firstChild, evt.targetItem.childNodes[evt.targetIndex]);
finishAddingIcon(evt.targetItem, evt.targetIndex);
}
}
if (evt.sourceItem.nodeName == 'DIS'){
if (evt.targetItem.nodeName == 'PG' || evt.targetItem.nodeName == 'FW_ENT' || (evt.targetItem.nodeName == 'RES' && evt.targetItem.attributes.type != 'label') || evt.targetItem.nodeName == 'KO'){
evt.targetItem.insertBefore(new XML('').firstChild, evt.targetItem.childNodes[evt.targetIndex]);
finishAddingIcon(evt.targetItem, evt.targetIndex);
}
}
if (evt.sourceItem.nodeName == 'DRW'){
if (evt.targetItem.nodeName == 'PG' || evt.targetItem.nodeName == 'FW_ENT' || (evt.targetItem.nodeName == 'RES' && evt.targetItem.attributes.type != 'label') || evt.targetItem.nodeName == 'KO'){
evt.targetItem.insertBefore(new XML('').firstChild, evt.targetItem.childNodes[evt.targetIndex]);
finishAddingIcon(evt.targetItem, evt.targetIndex);
}
}
if (evt.sourceItem.nodeName == 'SND'){
if (evt.targetItem.nodeName == 'PG' || evt.targetItem.nodeName == 'FW_ENT' || (evt.targetItem.nodeName == 'RES' && evt.targetItem.attributes.type != 'label') || evt.targetItem.nodeName == 'KO'){
evt.targetItem.insertBefore(new XML('').firstChild, evt.targetItem.childNodes[evt.targetIndex]);
finishAddingIcon(evt.targetItem, evt.targetIndex);
}
}
if (evt.sourceItem.nodeName == 'MOV'){
if (evt.targetItem.nodeName == 'PG' || evt.targetItem.nodeName == 'FW_ENT' || (evt.targetItem.nodeName == 'RES' && evt.targetItem.attributes.type != 'label') || evt.targetItem.nodeName == 'KO'){
evt.targetItem.insertBefore(new XML('').firstChild, evt.targetItem.childNodes[evt.targetIndex]);
finishAddingIcon(evt.targetItem, evt.targetIndex);
}
}
if (evt.sourceItem.nodeName == 'SCR'){
if (evt.targetItem.nodeName == 'LO' || evt.targetItem.nodeName == 'PG' || evt.targetItem.nodeName == 'FW_ENT' || (evt.targetItem.nodeName == 'RES' && evt.targetItem.attributes.type != 'label') || evt.targetItem.nodeName == 'KO'){
evt.targetItem.insertBefore(new XML('').firstChild, evt.targetItem.childNodes[evt.targetIndex]);
finishAddingIcon(evt.targetItem, evt.targetIndex);
}
}
if (evt.sourceItem.nodeName == 'PG'){
if (evt.targetItem.nodeName == 'FW' || evt.targetItem.nodeName == 'DEC' || evt.targetItem.nodeName == 'IFC' || evt.targetItem.nodeName == 'SND'){
evt.targetItem.insertBefore(new XML('').firstChild, evt.targetItem.childNodes[evt.targetIndex]);
finishAddingIcon(evt.targetItem, evt.targetIndex);
}
if (evt.targetItem.nodeName == 'INT'){
respTypes._visible = true;
respTypes.init(evt.targetItem, evt.targetIndex);
respTypes._x = iconPalette._x + iconPalette._width - 2;
respTypes._y = iconPalette._y + 92;
}
}
if (evt.sourceItem.nodeName == 'FW'){
if (evt.targetItem.nodeName == 'PG' || evt.targetItem.nodeName == 'FW_ENT' || (evt.targetItem.nodeName == 'RES' && evt.targetItem.attributes.type != 'label') || evt.targetItem.nodeName == 'KO'){
evt.targetItem.insertBefore(new XML('').firstChild, evt.targetItem.childNodes[evt.targetIndex]);
finishAddingIcon(evt.targetItem, evt.targetIndex);
}
}
if (evt.sourceItem.nodeName == 'FW_ENT'){
if (evt.targetItem.nodeName == 'FW' || evt.targetItem.nodeName == 'IFC'){
if (evt.targetItem.childNodes.length > 0) {
evt.targetItem.insertBefore(new XML('').firstChild, evt.targetItem.firstChild);
finishAddingIcon(evt.targetItem, 0);
} else {
evt.targetItem.appendChild(new XML('').firstChild);
finishAddingIcon(evt.targetItem, evt.targetIndex);
}
}
}
if (evt.sourceItem.nodeName == 'INT'){
if (evt.targetItem.nodeName == 'PG' || evt.targetItem.nodeName == 'FW_ENT' || (evt.targetItem.nodeName == 'RES' && evt.targetItem.attributes.type != 'label') || evt.targetItem.nodeName == 'KO'){
evt.targetItem.insertBefore(new XML('').firstChild, evt.targetItem.childNodes[evt.targetIndex]);
finishAddingIcon(evt.targetItem, evt.targetIndex);
}
}
if (evt.sourceItem.nodeName == 'DEC'){
if (evt.targetItem.nodeName == 'PG' || evt.targetItem.nodeName == 'FW_ENT' || (evt.targetItem.nodeName == 'RES' && evt.targetItem.attributes.type != 'label') || evt.targetItem.nodeName == 'KO'){
evt.targetItem.insertBefore(new XML('').firstChild, evt.targetItem.childNodes[evt.targetIndex]);
finishAddingIcon(evt.targetItem, evt.targetIndex);
}
}
}
dragCtrlList.dragFailed = function(evt){
evt.skip();
dragMouse.removeMovieClip();
Mouse.removeListener(mouseList);
}
dragCtrl.addEventListener("dragComplete", dragCtrlList);
dragCtrl.addEventListener("dragStart", dragCtrlList);
dragCtrl.addEventListener("dragFailed", dragCtrlList);
dragCtrl.setStyle("dropBorderColor", 0xFF6600 );
function finishAddingIcon(targetNode, targetIndex) {
tree.dataProvider = tree.dataProvider;
tree.setIsOpen(targetNode, true);
tree.selectedNode = tree.selectedItem.getTreeNodeAt(targetIndex);
//fire the change event
tree.dispatchEvent({type:'change', target:tree});
//select the name property for easy typing...
accord.selectedIndex = 0;
accord.propPane.propEdit.focusedCell = {columnIndex:1, itemIndex:0};
mdm.setwindowtitle('XERTE '+ contentXML.fileName + '*');
}
var _xml:XML = new XML('');
_xml.ignoreWhite = true
icTree.dataProvider = _xml;
//TOOL PALETTE//////////////////////////////////////////////////////////////////
toolBox.titleBar.onPress = function(){
this._parent.startDrag(false,0,0,800,600);
}
toolBox.titleBar.onRelease = function(){
this._parent.stopDrag();
}
toolTree = toolBox.toolTree.getTree();
toolBox.toolTree.dragRules = 15;
toolTree.labelFunction = function(){
return "";
}
toolTree.iconFunction = function(item) {
if (item.nodeName == 'PRE') {
return 'icPreview';
}
if (item.nodeName == 'CUT') {
return 'icCut';
}
if (item.nodeName == 'COPY') {
return 'icCopy';
}
if (item.nodeName == 'PASTE') {
return 'icPaste';
}
if (item.nodeName == 'DUPLICATE') {
return 'icDuplicate';
}
if (item.nodeName == 'HELP') {
return 'icHelp';
}
};
toolTree.vScrollPolicy = "off";
toolTree.setStyle('disclosureClosedIcon', 'icNull');
toolTree.setStyle('disclosureOpenIcon', 'icNull');
toolTree.setStyle('useRollOver ', false);
toolTree.setStyle('selectionColor ', 0xFFFFFF);
toolTree.setStyle('rollOverColor', 0xFFFFFF);
toolList = new Object();
toolList.double_click = function(evt:Object){
if (toolTree.selectedNode.nodeName == 'PRE'){
if (editor.FileLocation != ""){
F5Listener.mode = 'preview';
mdm.form_show("preview");
mdm.form_restore("preview");
saveFile();
mdm.form_callfunction("preview", "setMode", mode, "|");
mdm.form_callfunction("preview", "jumpFile", editor.FileLocation, "|");
}
}
if (toolTree.selectedNode.nodeName == 'CUT'){
cutIcon();
}
if (toolTree.selectedNode.nodeName == 'COPY'){
copyIcon();
}
if (toolTree.selectedNode.nodeName == 'PASTE'){
pasteIcon();
}
if (toolTree.selectedNode.nodeName == 'DUPLICATE'){
duplicateNode();
}
if (toolTree.selectedNode.nodeName == 'HELP'){
//launch help page...
_level0.helpURL = _level0.mdm_appdir+"help\\Xerte.chm";
fscommand("mdm.exec", "_level0.helpURL");
}
}
toolBox.toolTree.addEventListener('double_click', toolList);
var _xml:XML = new XML('');
_xml.ignoreWhite = true
toolTree.dataProvider = _xml;
stop();