jsfl help

New Here ,
Nov 22, 2019 Nov 22, 2019

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;

TOPICS
Code, How to

Views

238

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct Answers

Participant , Nov 23, 2019 Nov 23, 2019
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[...

Likes

Translate

Translate
Adobe Community Professional , Nov 23, 2019 Nov 23, 2019
(and 1 is the multiplicative identity.)

Likes

Translate

Translate
Participant ,
Nov 23, 2019 Nov 23, 2019

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;

 

 

 

- Vlad: UX and graphic design, Flash user since 1998
Member of Flanimate Power Tools team - extensions for character animation

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Nov 23, 2019 Nov 23, 2019

Copy link to clipboard

Copied

LATEST

(and 1 is the multiplicative identity.)

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines