Sg2.9
TypeError: Cannot read proper...
Recent RSS
TypeError: Cannot read property "characterStyle" from undefined
From:  Doeke Wartena
Date:  19. March 2010, 10:24

I got this error but everything works fine:

TypeError: Cannot read property "characterStyle" from undefined
at My Scripts/doeke/baselineShift1.js:17

is this a scriptographer bug?

here's the script:

//
var selectedTextItem = document.getItems({
	type: TextItem,
	selected: true
});
	
if (selectedTextItem.length > 0) {
	var item = selectedTextItem[0];
	//item.remove();
	var xChars = item.range.characters.length;
	print("xCharacters "+xChars);
	
	var yShift = 0;
	var step = 0.03
	var dir = 1;
	
	for (var i = 0; i <= xChars; i++){
		item.range.characters[i].characterStyle.baselineShift = yShift;
		
		yShift +=step*dir;
		if (yShift >= 1 || yShift <= 0){
			dir = -dir;;
		}
	}
	
} else {
	Dialog.alert('Please select a textItem first!');
}
//
Re: TypeError: Cannot read property "characterStyle" from undefi
Date:  19. March 2010, 11:20

Hi Doeke,

The problem is in line 17:

for (var i = 0; i <= xChars; i++){

which should be changed to

for (var i = 0; i < xChars; i++){
Re: TypeError: Cannot read property "characterStyle" from undefi
From:  Doeke Wartena
Date:  19. March 2010, 11:54

thx

Scripts
08.08.14, 15:24
15.05.14, 14:23
02.03.14, 19:16
18.11.13, 14:48
22.03.13, 03:05
22.02.13, 15:45
Posts
10.01.17, 16:37
19.02.16, 06:03
19.02.16, 06:00
17.01.16, 11:00
12.01.16, 13:10
25.11.15, 08:19
Script of the Moment
objects on paths (scatter brush) 29.07.12