Thursday, December 08, 2005

My action script

The action script for the txt to speech:

var messages = Array();
// load in XML
sms = new XML();
sms.ignoreWhite = true;
sms.onLoad = function(success) {
if (success) {
var arr;
txtone = "";
arr = sms.firstChild.firstChild.childNodes[1];
var flag = false;
var next = 0;
while (!flag) {
if (arr.childNodes[0].childNodes[5].nodeName != "false") {
flag = true;
txtone = arr.childNodes[0].childNodes[3].firstChild+"z";
}
next++;
}
}

if (txtone.charAt(1) == ":") {
if (txtone.substring(0, 2) == "1:") {
txtone = removeHeader(txtone);
oneText.text = txtone;
} else if (txtone.substring(0, 2) == "2:") {
txtone = removeHeader(txtone);
twoText.text = txtone;
} else if (txtone.substring(0, 2) == "3:") {
txtone = removeHeader(txtone);
threeText.text = txtone;
} else if (txtone.substring(0, 2) == "4:") {
txtone = removeHeader(txtone);
fourText.text = txtone;
} else if (txtone.substring(0, 2) == "5:") {
txtone = removeHeader(txtone);
fiveText.text = txtone;
} else if (txtone.substring(0, 2) == "6:") {
txtone = removeHeader(txtone);
sixText.text = txtone;
} else if (txtone.substring(0, 2) == "7:") {
txtone = removeHeader(txtone);
sevenText.text = txtone;
} else if (txtone.substring(0, 2) == "8:") {
txtone = removeHeader(txtone);
eightText.text = txtone;
} else if (txtone.substring(0, 2) == "9:") {
txtone = removeHeader(txtone);
nineText.text = txtone;
}
} else {
trace("error");
}
}

onEnterFrame = function () {
sms.load("contents.plist");
};
function removeHeader(editString) {
//invoke new String obj called 'temp'
var temp = new String();
temp = editString.substring(2);
return temp;
}

0 Comments:

Post a Comment

<< Home