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

jsfl help

New Here ,
Nov 22, 2019 Nov 22, 2019

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

(and 1 is the multiplicative identity.)

Translate
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].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
Translate
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
LATEST

(and 1 is the multiplicative identity.)

Translate
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