I downloaded the barcode module, copied the folder into my projects root directory, added the <module version="1.0">ti.barcode</module> to tiapp.xml, and copied the example into the app.js file.
When I run the iPhone simulator and press the "Scan QR Code" button, nothing happens and I get this error in the Console:
[WARN] Exception in event callback. {
expressionBeginOffset = 462;
expressionCaretOffset = 478;
expressionEndOffset = 486;
line = 25;
message = "Result of expression 'Titanium.Barcode' [undefined] is not an object.";
name = TypeError;
sourceId = 199841424;
sourceURL = "file://localhost/Users/KG/Projects/Titanium%20Studio%20Workspace/QRtest/Resources/app.js";
}
Any help is appreciated...
6 Answers
The project module will be need copied to /Library/Application Support/Titanium/modules/iphone/ and not to project folder.
Thanks for the help. I copied the project module to /Library/Application Support/Titanium/modules/iphone/ and I'm still getting the same error. Here's my app.js code:
var barcode = require("ti.barcode"); // open a single window var window = Ti.UI.createWindow({ backgroundColor:'white' }); window.open(); var button = Ti.UI.createButton({ title:"Scan QR Code", width:150, height:40, top:20 }); window.add(button); button.addEventListener('click',function() { Titanium.Barcode.capture({ success: function(event) { alert("success = "+event.result); }, cancel: function(event) { alert("cancel"); }, error: function(event) { alert("Error. "+event.message); } }); });
I found the problem...
The sample code provided by the module 1.0 has this code at the top:
barcode = require("ti.barcode")
But later calls Titanium.barcode. Thus the above code needs to be:
Titanium.barcode = require("ti.barcode")
if you initialize it as `Titanium.barcode = ti.barcode = require("ti.barcode") you can then use either format to call the module methods.
I don't have experience on reading barcodes, by you can look into this link to find how to create them: EAN 128/ GS1 128 Barcode Add-In for ExcelYou may try it someday
i use ti.barcode module and i've this this error since one week. i don't undestand why. can you help me, please ?
Your Answer
Think you can help? Login to answer this question!