Copy link to clipboard
Copied
when I do this it doesn't work
var x = fl.getDocumentDOM().getTimeline().layers[0].frames[0].elements[0].x;
var y = fl.getDocumentDOM().getTimeline().layers[0].frames[0].elements[0].y;
x += (Math.random()*2-1)*3*1;
y += (Math.random()*2-1)*3*1;
Hi,
In my observations, X and Y properties of an element return a copy of their values, so you can't store a reference to the "live" property, to manipulate it directly.
In your example, first you get a copy of the values. Next you modify the copies. If you assign the modified copies back to the element, you will achieve what you want.
// get values
var x = fl.getDocumentDOM().getTimeline().layers[0].frames[0].elements[0].x;
var y = fl.getDocumentDOM().getTimeline().layers[0].frames[0].elements[0
...
(and 1 is the multiplicative identity.)
Copy link to clipboard
Copied
Hi,
In my observations, X and Y properties of an element return a copy of their values, so you can't store a reference to the "live" property, to manipulate it directly.
In your example, first you get a copy of the values. Next you modify the copies. If you assign the modified copies back to the element, you will achieve what you want.
// get values
var x = fl.getDocumentDOM().getTimeline().layers[0].frames[0].elements[0].x;
var y = fl.getDocumentDOM().getTimeline().layers[0].frames[0].elements[0].y;
// modify
x += (Math.random()*2-1)*3*1;
y += (Math.random()*2-1)*3*1;
// assign them back
fl.getDocumentDOM().getTimeline().layers[0].frames[0].elements[0].x = x;
fl.getDocumentDOM().getTimeline().layers[0].frames[0].elements[0].y = y;
Copy link to clipboard
Copied
(and 1 is the multiplicative identity.)