Save/Load User Inputs from Scripted GUI in ExtendScript? - extendscript

I'm creating a very simple GUI in ExtendScript and I'd like to know how to save and open any user inputs from the "edittext" boxes that I've created. How would I be able to add a "file>save" and "file>open" menu to save and retrieve any user inputs?
//GUI Design
var myWin = new Window ("palette", "EditTextTest", undefined);
myWin.orientation = "row";
var groupOne = myWin.add("group", undefined, "GroupOne");
groupOne.orientation = "column";
groupOne.add("statictext", undefined, "Player 01 Name");
var etOne = groupOne.add("edittext", undefined, "");
etOne .characters = 10;
groupOne.add("statictext", undefined, "Player 02 Name");
var etTwo = groupOne.add("edittext", undefined, "");
etTwo .characters = 10;
groupOne.add("statictext", undefined, "Player 03 Name");
var etThree = groupOne.add("edittext", undefined, "");
etThree .characters = 10;
groupOne.add("statictext", undefined, "Player 04 Name");
var etFour = groupOne.add("edittext", undefined, "");
etFour .characters = 10;
groupOne.add("statictext", undefined, "Player 05 Name");
var etFive = groupOne.add("edittext", undefined, "");
etFive .characters = 10;
myWin.center();
myWin.show();

If you are developing for AE, you can use the following to store and retrieve values in app's native preference file:
app.settings.haveSetting("myScriptPrefCategory", "myControl"); //Check for saved pref value
app.settings.saveSetting("myScriptPrefCategory", "myControl", "controlValue"); //Saves a pref value
app.settings.getSetting("myScriptPrefCategory", "myControl"); //Retrieves a pref value
I learned this from David Torno. See this forum thread at the AE Scripting Forums.
Upon initialization of your code, you can lookup the preference that you've created, then setup your UI to reflect the values stored in that preference file.

Related

How do I add listbox to tab1 and something else in tab2?

Here is my code and I can't seem to get Listbox or anything to show up.
I found the main code posted on other forums.
I only added the Listbox code however I cannot seem to see any of my objects visible, not sure what’s happening.
var dlg = new Window ("dialog", "Abas", [0,0,0,0]);
dlg.size = [240, 120]
dlg.location = [415, 230]
var tpanel = dlg.add ("tabbedpanel" ,[10,10,0,0],);
tpanel.size = [220,100];
dlg.location = [10, 10];
var general = tpanel.add ("tab", [0,0,0,0], "Color");
var general1 = dlg.add('tabbedpanel')
var boo_tab = general1.add('tab', u, "Create Solids");
var t = boo_tab.add("statictext", undefined, "Hello", {multiline:false});
t.text = "Create Solids";
var listBox = tpanel.add("listbox", undefined, []);
listBox.selection = 0;
listBox.size = [300, 100];
listBox.add("item", "Create 2 solids");
listBox.add("item", "Create Solid");
listBox.add("item", "Create Solid dlgith fractual noise");
var images = tpanel.add ("tab", undefined, "Levels");
var img_options = images.add ("panel", undefined, "Image Options");
var buttons = dlg.add ("group");
buttons.add ("button", undefined, "Export", {name: "ok"});
buttons.add ("button", undefined, "Cancel");
var images1 = tpanel.add ("tab", undefined, "Curves");
var img_options = images1.add ("panel", undefined, "Image Options");
var buttons = dlg.add ("group");
buttons.add ("button", undefined, "Export", {name: "ok"});
buttons.add ("button", undefined, "Cancel");
tpanel.selection = 0;
dlg.center();
dlg.show ();
There appears to be quite a few things wrong with this code and it is difficult to figure out exactly what you are hoping to achieve.
The first thing that I'm noticing is that you are adding some objects to the tabbed panel instead of the tabs themselves.
For instance, you can't add listbox to tpanel because tpanel will only be expecting tab objects. Instead add listbox to either a group or a tab object. For instance, you could add it to your boo_tab object like so:
var listBox = boo_tab.add("listbox", undefined, []);
The same is true with images1. It cannot be added to tpanel. So you will need to choose where you want it.
I can't tell for certain if it was your intention to create a second tabbed panel general1 under the first one or if you just wanted it to be a new tab. If you wanted a new tabbed panel you are going to want to put both tabbed panels in their own groups.
It also looks like you want to add some buttons to the bottom. I believe, in order for this to work the way you want, you will also need to put tpanel in its own group.
I would like to suggest that while you are learning, you only add one item at a time. This way, if something goes wrong, you only have to troubleshoot one thing at a time and it is easier to discover where mistakes have been made.

Is an nlobjSearchResultSet and nlobjSearch serializable during nlapiYieldScript and nlapiSetRecoveryPoint?

I was just wondering if anybody knew if these objects are serializable for a yield or recovery.
NetSuite documentation states that the following is serializable (and thus restorable during a yield):
All JavaScript native types
nlobjConfiguration
nlobjContext
nlobjError
nlobjFile (files up to 5MB in size)
nlobjRecord
nlobjSubrecord
nlobjSearchColumn
nlobjSearchFilter
nlobjSearchResult
nlobjSearchResultCell
all 3rd party XML Library objects
I just found it curious that neither was listed in that list.
nlobjSearch certainly didn't used to be and I don't think result sets were either.
I generally ended up wrapping my search in function and returning an array of values to avoid serializable exceptions.
e.g.
function batchStatements(){
var statementCusts = (function(){
var allowResend = 'T' == nlapiGetContext().getSetting('SCRIPT', 'custscript_kotn_statement_resend');
var filters = [
sf('balance', null, 'greaterthanorequalto', 35), // over the threshhold
sf('emailtransactions', null, 'is','T'),
sf('custentity_kotn_suppress_statements', null, 'is', 'F')
];
if(!allowResend){
var resendCutoffDays = parseInt(nlapiGetContext().getSetting('SCRIPT', 'custscript_kotn_resend_limit'),10) || 14;// 14 days allows bi-montly batches if desired.
var resendCutoff = new Date(new Date().getTime() - resendCutoffDays * 24 * 3600 * 1000);
nlapiLogExecution("DEBUG", "limit statements since "+ resendCutoff.toISOString());
filters.push(sf('custentity_kotn_last_statement', null, 'notafter', nlapiDateToString(resendCutoff)));
}
var srch = nlapiCreateSearch('customer',
filters,
[
sc('entityid'),
sc('custentity_kotn_billing_email'),
sc('email'),
sc('subsidiary')
]);
var custs = [];
var accum = function(res){
custs.push({
id:res.getId(),
billingEmail: res.getValue('custentity_kotn_billing_email'),
email:res.getValue('email'),
name:res.getValue('entityid'),
subsidiary:res.getValue('subsidiary')
});
return true;
}
srch.runSearch().forEachResult(accum);
return custs;
})();
var testEnt = {};
simpleBatch(statementCusts, function(cust){
nlapiLogExecution("AUDIT", "Sending Statement for "+ cust.name);
var entityComms = entityPreferences.getCustEntity(cust.id);
var pdfFile = generateStatement(cust.id);
var emailFile = kotnMergeTemplate(entityComms.statementEmailTemplate, 'customer', cust.id);
nlapiSendEmail(entityComms.emailFromEmp, cust.billingEmail || cust.email || entityComms.actionEmp, emailFile.getName(), emailFile.getValue(), null, null, {entity:cust.id}, pdfFile, true);
});
}
simpleBatch is from https://github.com/BKnights/KotN-Netsuite
it handles governance management by tracking the max governance of the function and yielding when needed.

Wants to search the fileld value from Contract record in Purchase order record

I was searching for a value from contract record in Purchase record but i am unable to get the field where the value is. Below is the code for that. I am applying this code for the contract record and the function is for before submit.
I think I am applying the search in wrong way.
function srchfield()
{
var recordid = nlapiGetRecordId() //retunrs the contract id
nlapiLogExecution('DEBUG', 'recordid ', recordid );
var recordtype = nlapiGetRecordType(); //retunrs the contract recordtype = jobs
nlapiLogExecution('DEBUG', 'RecordType', recordtype);
var loadrecord = nlapiLoadRecord(recordtype, recordid); //loads the record
nlapiLogExecution('DEBUG', 'Load Record', loadrecord );
var contractname = nlapiGetFieldValue('entityid'); //returs the value of the field contractname whose fieldid is = entityid
nlapiLogExecution('DEBUG', 'ContractName ', contractname );
var filters = new Array();
new nlobjSearchFilter('entityid', null, 'anyof', contractname ); // entityid is field id in contract Record and contractname is defined above for contract record
// nlapiLogExecution('DEBUG', 'SearchFilter', filters );
var columns = new Array();
new nlobjSearchColumn('custbodycontract'); // custbodycontractis field id in PO Record
var searchresults = nlapiSearchRecord('purchaseorder', null, filters, columns);
for ( var i = 0; searchresults != null && i < searchresults.length; i++ )
{
var searchresult = searchresults[ i ];
var record = searchresult.getId( );
var rectype = searchresult.getRecordType( );
var cntrct_name= searchresult.getValue( 'custbodycontract' );
}
}
Thanks in advance
****Update: I have completed my answer based on the comments provided. Please see at the last section. I hope it helps. Thanks!***
**I might provide you the snippet if you will explain this further. Please advise
If I understand correctly your code, these are what you are doing and you want to do:
Your contract record is the native entity record - project/job. It had just been renamed to contract by your functional consultant.
You have an user event script (SuiteScript 1.0) before submit and deployed to the contract (project/job) record.
Using the information from the contract record (in this case using the contract name (entityid), you wanted to search for POs to get 'custbodycontract' at the header.
Then you are filtering the search on POs using "entityid" but PO doesnt have that native field on the header. It only has it on the expense line and item line but the id is 'customer'.
Can you explain how is the contract record related to PO. Which field (native/custom) is available on PO that can be used as a join on contract record?
Then, please take note this best practice as freebie.
To optimize your script. You don't need to use nlapiLoadRecord on beforesubmit. Please see below the best practice.:
- With beforesubmit and if you are only getting or setting values on the script deployed record, use nlapiGet** and nlapiSet** API.
- On beforesubmit, only use nlapiLoadRecord if you are getting and setting the value on the sublist of a different record. But utilize first nlapiSearchRecord if you are only getting value at the line level (different record). If it will not give what you need, use nlapiLoadRecord.
- On aftersubmit, only use nlapiLoadRecord if you are setting and getting value at the line level of the deployed record and different record. If you are only getting value at the level, same practice with beforesubmit.
- On aftersubmit, use nlapiLookUp for getting value from the header, and nlapiSubmitField if you are setting. Only use nlapiLoadRecord if it doesnt give you what you need.
****This might what you need...
function srchfield()
{
var stRecordid = nlapiGetRecordId(); /*retunrs the contract id*/
nlapiLogExecution('DEBUG', 'recordid ', stRecordid);
var stRecordtype = nlapiGetRecordType(); /*retunrs the contract recordtype = jobs*/
nlapiLogExecution('DEBUG', 'RecordType', stRecordtype);
var stContractname = nlapiGetFieldValue('entityid'); /*returs the value of the field contractname whose fieldid is = entityid*/
nlapiLogExecution('DEBUG', 'ContractName ', stContractname);
var arrFilters = new Array();
arrFilters.push(new nlobjSearchFilter('type', null, 'anyof',
[
'PurchOrd'
])); /*As best practice, instead of directly searching on POs, add filter for transaction type since you might use this later in other transaction.*/
arrFilters.push(new nlobjSearchFilter('mainline', null, 'is', 'T')); /*This is to exclude line level results*/
arrFilters.push(new nlobjSearchFilter('custbodycontract', null, 'is', stContractname));
var arrColumns = new Array();
arrColumns.push(new nlobjSearchColumn('trandate')); /*I just wanted to include this column on the result. :)*/
arrColumns.push(new nlobjSearchColumn('type')); /*I just wanted to include this column on the result. :)*/
arrColumns.push(new nlobjSearchColumn('tranid')); /*I just wanted to include this column on the result. :)*/
arrColumns.push(new nlobjSearchColumn('custbodycontract')); /*This is what you need.*/
var arrSearchresults = nlapiSearchRecord('transaction', null, arrFilters, arrColumns);
for (var i = 0; arrSearchresults != null && i < arrSearchresults.length; i++)
{
var objResult = arrSearchresults[i];
var stRecId = objResult.getId();
var stRecType = objResult.getRecordType();
var stCntrctName = objResult.getValue('custbodycontract');
}
The problem I notice on your code is the creation of the filter.
You instantiated nlobjSearchFilter but you didn't push it in an array. So basically, you are searching without filter.
And I believe your search criteria were complete.
Try below codes. By the way make sure that the field type of custbodycontract is a freeform text to properly compare it with the entityid of the contract record.
function srchfield()
{
var stRecordid = nlapiGetRecordId(); /*retunrs the contract id*/
nlapiLogExecution('DEBUG', 'recordid ', stRecordid);
var stRecordtype = nlapiGetRecordType(); /*retunrs the contract recordtype = jobs*/
nlapiLogExecution('DEBUG', 'RecordType', stRecordtype);
var stContractname = nlapiGetFieldValue('entityid'); /*returs the value of the field contractname whose fieldid is = entityid*/
nlapiLogExecution('DEBUG', 'ContractName ', stContractname);
var arrFilters = new Array();
arrFilters.push(new nlobjSearchFilter('type', null, 'anyof',
[
'PurchOrd'
])); /*As best practice, instead of directly searching on POs, add filter for transaction type since you might use this later in other transaction.*/
arrFilters.push(new nlobjSearchFilter('mainline', null, 'is', 'T')); /*This is to exclude line level results*/
arrFilters.push(new nlobjSearchFilter('custbodycontract', null, 'is', stContractname));
var arrColumns = new Array();
arrColumns.push(new nlobjSearchColumn('trandate')); /*I just wanted to include this column on the result. :)*/
arrColumns.push(new nlobjSearchColumn('type')); /*I just wanted to include this column on the result. :)*/
arrColumns.push(new nlobjSearchColumn('tranid')); /*I just wanted to include this column on the result. :)*/
arrColumns.push(new nlobjSearchColumn('custbodycontract')); /*This is what you need.*/
var arrSearchresults = nlapiSearchRecord('transaction', null, arrFilters, arrColumns);
for (var i = 0; arrSearchresults != null && i < arrSearchresults.length; i++)
{
var objResult = arrSearchresults[i];
var stRecId = objResult.getId();
var stRecType = objResult.getRecordType();
var stCntrctName = objResult.getValue('custbodycontract');
}
}

RaphaelJs - Issues with Hovering due to Object

Cheers,
for my website I try to spice my CV a little up.
If you hover about an Icon on canvas_2, which I created as an Object, a static shape + dynamic message will appear on canvas_3 (canvas_1 is solely for navigation, which does not matter at this point). However if I hover over the first Object, the second Object, not the first, fires its animation and displays the description.
I set up a fiddle, maybe this will clear things up better than my english.
http://jsfiddle.net/J6h7e/4/
function Achievement(set, rect, circ, symb, label, text, icon)
{
var ach = this;
ach.set = set;
ach.rect = rect;
ach.circ = circ;
ach.symb = symb;
ach.lab = label;
ach.desText = text;
ach.desIcon = icon;
ach.builder = function()
{
ach.cir = canvas_2.path(circ);
ach.sym = canvas_2.path(symb);
ach.set.push(ach.rect, ach.sym, ach.cir);
ach.set.attr({"stroke":"none", "fill":"rgb(238, 238, 238)"});
ach.rect.attr({"opacity":0});
}
ach.hoverSetup = function()
{
ach.set.mouseover(
function(){
ach.set.forEach(function(el){el.animate(el.transform("s1.25"), "bounce")});
achTemplate.attr({"opacity":1});
ach.description.attr({"opacity":1});
}
);
ach.set.mouseout(
function(){ach.set.forEach(function(el){el.animate(el.transform("s1"), "elastic")});
achTemplate.attr({"opacity":0});
ach.description.attr({"opacity":0});
}
)
}
ach.descriptor = function()
{
canvas_3.setStart();
ach.des = canvas_3.text(320, 60, ach.desText);
ach.ico = canvas_3.path(ach.desIcon).attr({"stroke":"none"});
ach.description = canvas_3.setFinish();
ach.description.attr({"font-family":"cabinregular", "font-size":"14px", "fill":"rgb(25,106,141)", "text-anchor":"start", "opacity":0});
}
console.log(ach.set);
return ach;
}
/*Static Content*/
var title = canvas_2.text(200, 20, 'Achievements');
title.attr({"font-family": 'franchiseregular',"font-size": '24','stroke-width': '0','stroke-opacity': '1','fill': 'rgb(238,238,238)'});
var achTemplate = canvas_3.set();
var templ = canvas_3.path("M635.5,57c0,27.615-18.851,50-42.105,50H277.605c-23.253,0-42.105-22.385-42.105-50l0,0 c0-27.613,18.853-50,42.105-50h315.789C616.649,7,635.5,29.387,635.5,57L635.5,57z");templ.attr({"stroke":"none", "fill":"rgb(238,238,238)"});
var templHe = canvas_3.text(410, 20, "Achievement Unlocked");
templHe.attr({"font-family":"cabinsemibold", "font-size":"18px", "fill":"rgb(25, 106, 141)", "font-weight":"bold" });
var tempCir = canvas_3.path("M260.75,55.884c0-0.714,0.04-1.417,0.117-2.111l-10.838-3.522c-0.346,1.824-0.529,3.707-0.529,5.633 c0,8.626,3.644,16.404,9.472,21.875l6.696-9.217C262.614,65.206,260.75,60.762,260.75,55.884z M298.25,55.884 c0,4.877-1.863,9.322-4.918,12.658l6.695,9.217c5.828-5.471,9.473-13.248,9.473-21.875c0-1.926-0.184-3.809-0.531-5.632 l-10.84,3.521C298.21,54.466,298.25,55.169,298.25,55.884z M283.25,37.509c5.387,1.093,9.934,4.495,12.566,9.131l10.84-3.521 c-4.29-9.107-13.024-15.706-23.406-17.003V37.509z M263.184,46.642c2.631-4.634,7.18-8.037,12.566-9.131V26.117 c-10.382,1.297-19.116,7.896-23.404,17.004L263.184,46.642z M287.266,72.954c-2.365,1.078-4.992,1.68-7.766,1.68 c-2.773,0-5.4-0.602-7.766-1.68l-6.698,9.217c4.29,2.365,9.219,3.713,14.463,3.713s10.174-1.348,14.464-3.713L287.266,72.954z");
tempCir.attr({"stroke":"none", "fill":"rgb(25, 106, 141)"});
achTemplate.push(templ, templHe, tempCir);
achTemplate.attr({"opacity":0});
var tooltip = canvas_3.path("M34.308,44c-3.472,0-6.737,1.352-9.192,3.808c-2.456,2.455-3.808,5.721-3.808,9.192s1.352,6.737,3.808,9.192 C27.57,68.648,30.836,70,34.308,70s6.737-1.352,9.192-3.808c2.456-2.455,3.808-5.721,3.808-9.192s-1.352-6.737-3.808-9.192 C41.045,45.352,37.779,44,34.308,44z M34.308,41L34.308,41c8.837,0,16,7.163,16,16s-7.163,16-16,16s-16-7.163-16-16 S25.471,41,34.308,41z M32.308,63h4v4h-4V63z M32.308,47h4v12h-4V47z");
tooltip.attr({"stroke":"none", "fill":"rgb(238, 238, 238)", "title":"Hover over the Symbols to get more Information"});
/*Berlin Achievement */
var ber = canvas_2.set();
var selBe = canvas_2.rect(89.466, 109, 60.001, 60);
var berlin = Achievement
(
ber,
selBe,
"M100.92,138.885c0-0.714,0.039-1.417,0.117-2.111L90.2,133.251c-0.347,1.824-0.529,3.707-0.529,5.633 c0,8.626,3.644,16.404,9.472,21.875l6.696-9.217C102.784,148.207,100.92,143.763,100.92,138.885z M138.42,138.885 c0,4.877-1.863,9.322-4.918,12.658l6.695,9.217c5.828-5.471,9.473-13.248,9.473-21.875c0-1.926-0.184-3.809-0.531-5.632 l-10.84,3.521C138.381,137.467,138.42,138.169,138.42,138.885z M123.42,120.51c5.387,1.093,9.934,4.495,12.566,9.131l10.84-3.521 c-4.289-9.107-13.023-15.706-23.406-17.003V120.51z M103.354,129.642c2.631-4.634,7.18-8.037,12.566-9.131v-11.395 c-10.383,1.297-19.116,7.896-23.404,17.004L103.354,129.642z M127.436,155.955c-2.365,1.078-4.992,1.68-7.766,1.68 s-5.4-0.602-7.766-1.68l-6.699,9.217c4.291,2.365,9.22,3.713,14.463,3.713c5.246,0,10.176-1.348,14.465-3.713L127.436,155.955z",
"M119.67,126.938c-4.143,0-7.5,3.357-7.5,7.5c0,7.5,7.5,16.5,7.5,16.5s7.5-9,7.5-16.5 C127.17,130.295,123.813,126.938,119.67,126.938z M119.67,139.033c-2.537,0-4.594-2.057-4.594-4.594s2.057-4.594,4.594-4.594 s4.594,2.057,4.594,4.594S122.208,139.033,119.67,139.033z M116.765,134.438c0,1.605,1.301,2.906,2.906,2.906 c1.604,0,2.905-1.301,2.905-2.906s-1.301-2.906-2.905-2.906C118.065,131.533,116.765,132.833,116.765,134.438z",
"The Passenger",
"250G - The Passenger \n Moved to Berlin \n Unlocked on 09/08/2004",
"M279.764,44.938c-4.143,0-7.5,3.357-7.5,7.5c0,7.5,7.5,16.5,7.5,16.5s7.5-9,7.5-16.5 C287.264,48.295,283.906,44.938,279.764,44.938z M279.764,57.031c-2.537,0-4.594-2.056-4.594-4.593s2.057-4.594,4.594-4.594 s4.594,2.057,4.594,4.594S282.301,57.031,279.764,57.031z M276.858,52.438c0,1.605,1.301,2.906,2.906,2.906 c1.605,0,2.906-1.301,2.906-2.906s-1.301-2.906-2.906-2.906C278.159,49.532,276.858,50.833,276.858,52.438z"
);
berlin.builder();
berlin.hoverSetup();
berlin.descriptor();
/*Python Achievement */
var py = canvas_2.set();
var selPy = canvas_2.rect(89.795, 362.5, 60, 60);
var python = Achievement
(
py,
selPy,
"M101.045,392.384c0-0.713,0.04-1.416,0.117-2.109l-10.839-3.521c-0.347,1.824-0.528,3.707-0.528,5.633 c0,8.627,3.645,16.405,9.473,21.876l6.695-9.217C102.91,401.706,101.045,397.262,101.045,392.384z M138.545,392.384 c0,4.878-1.863,9.322-4.918,12.659l6.695,9.217c5.828-5.471,9.473-13.249,9.473-21.876c0-1.926-0.184-3.809-0.531-5.631 l-10.84,3.521C138.506,390.966,138.545,391.669,138.545,392.384z M123.545,374.009c5.387,1.094,9.934,4.496,12.566,9.132 l10.84-3.521c-4.289-9.107-13.023-15.707-23.406-17.004V374.009z M103.48,383.142c2.631-4.635,7.18-8.037,12.564-9.131v-11.395 c-10.382,1.297-19.115,7.896-23.402,17.004L103.48,383.142z M127.561,409.455c-2.363,1.078-4.99,1.68-7.766,1.68 c-2.771,0-5.398-0.602-7.767-1.68l-6.697,9.217c4.29,2.365,9.22,3.713,14.463,3.713c5.245,0,10.175-1.348,14.464-3.713 L127.561,409.455z",
"M127.295,390.938h-1.5v-4.5c0-3.313-2.688-6-6-6s-6,2.688-6,6v4.5h-1.5c-0.824,0-1.5,0.678-1.5,1.5v10.5 c0,0.825,0.676,1.501,1.5,1.501h15c0.824,0,1.5-0.676,1.5-1.501v-10.5C128.795,391.614,128.119,390.938,127.295,390.938z M119.795,399.938c-0.828,0-1.5-0.671-1.5-1.5c0-0.828,0.672-1.5,1.5-1.5c0.83,0,1.5,0.672,1.5,1.5 C121.295,399.268,120.625,399.938,119.795,399.938z M122.795,390.938h-6v-4.5c0-1.652,1.348-3,3-3c1.654,0,3,1.348,3,3V390.938z",
"Rattlesnake",
"250G - Rattlesnake \n Mastering Python \n Not yet Unlocked",
"M287.264,54.5h-1.5V50c0-3.313-2.688-6-6-6c-3.313,0-6,2.687-6,6v4.5h-1.5c-0.824,0-1.5,0.676-1.5,1.5v10.5 c0,0.824,0.676,1.5,1.5,1.5h15c0.824,0,1.5-0.676,1.5-1.5V56C288.764,55.176,288.088,54.5,287.264,54.5z M279.764,63.5 c-0.829,0-1.5-0.671-1.5-1.5s0.671-1.5,1.5-1.5s1.5,0.671,1.5,1.5S280.593,63.5,279.764,63.5z M282.764,54.5h-6V50 c0-1.654,1.346-3,3-3c1.654,0,3,1.346,3,3V54.5z"
);
python.builder();
python.hoverSetup();
python.descriptor();
}
You have missed the new keyword when creating new instance of the Achievement object.
like:
var berlin = new Achievement();
var python = new Achievement();
http://jsfiddle.net/J6h7e/5/
BTW: Nice animation :)

Titanium: Error trying to play a sound when tapping a row in a table?

I'm making a rather simple app that displays a table where each row contains an English word and the corresponding Polish word. When a row is pressed it should play a sound clip of the word expressed. However, I cannot make it work, even though I've tried to troubleshoot it with all that Google has to offer. Would appreciate if someone could point out the flaw...
var win = Titanium.UI.currentWindow;
var data =[];
var CustomData = [
{ file:'001', english:'Do you?', polish:'Czy masz?', fav:false },
{ file:'002', english:'How long?', polish:'Jak d?ugo?', fav:false },
{ file:'003', english:'Is it?', polish:'Czy?', fav:false },
];
var section = Ti.UI.createTableViewSection();
data.push(section);
for (var i=0; i<CustomData.length; i++) {
var row = Ti.UI.createTableViewRow({layout : 'vertical', height:'auto'});
var item = Ti.UI.createLabel({
color:'#000',
text:CustomData[i].english,
font:{fontSize:12, fontWeight:'bold'},
top:3,
left:10,
right:30,
height:'auto'
});
row.add(item);
var cost = Ti.UI.createLabel({
color:'#444',
text:CustomData[i].polish,
font:{fontSize:12},
top:0,
left:15,
right:30,
bottom:5,
height:'auto'
});
row.add(cost);
row.filter = CustomData[i].english;
section.add(row);
};
var tableview = Titanium.UI.createTableView({
data:data, search:search, searchHidden:false, filterAttribute: 'filter' });
win.add(tableview);
tableview.addEventListener('click', function(e)
{
var sound = Titanium.Media.createSound();
sound.url = '../sound/' + e.rowData.file + '.mp3';
sound.play();
if (e.rowData.test)
{
var win = Titanium.UI.createWindow({
url:e.rowData.test,
title:e.rowData.title
});
Titanium.UI.currentTab.open(win,{animated:true});
}
});
Just a shot in the dark, but are you sure you can set the URL after the sound object is created? Have you tried:
Titanium.Media.createSound({url:'../sound/' + e.rowData.file + '.mp3'});
Aside from that, are you sure the relative URL is evaluated from where you think? Maybe try it with an absolute URL just to be sure.

Resources