• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

395

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

Engaged , 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[0
...

Votes

Translate

Translate
Community Expert , Nov 23, 2019 Nov 23, 2019

(and 1 is the multiplicative identity.)

Votes

Translate

Translate
Engaged ,
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

Votes

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
Community Expert ,
Nov 23, 2019 Nov 23, 2019

Copy link to clipboard

Copied

LATEST

(and 1 is the multiplicative identity.)

Votes

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