试图乘以一个值

时间:2014-06-11 17:18:23

标签: javascript arrays

我有一个对象,它给了我一个非常小的值,我想将它乘以一个数字,以便在X轴上看到一个更大的对象变化。

var y = 10;

function initialize()
{

}

function On_finger1()
{

var positionArray = finger1.value.toArray();

// x y z = index0 index1 index2

// variable called currentZ which has taken the 3rd value
var currentX = positionArray[0];

currentX = y * 1000;

}

我正从数组中捕获值,但它似乎没有进入对象。

1 个答案:

答案 0 :(得分:1)

如果要更新数组中的索引,则需要更新数组的索引。

var currentX = positionArray[0];  //<--just getting the data that is in that index, it is not a pointer.

currentX = y * 1000;  //<--just overridding what was in the varaiable

我认为你想要的只是

positionArray[0] = y * 1000;