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

Assuming that the drawing object is a group, how to add a stroke to it using jsfl?

Participant ,
Sep 23, 2023 Sep 23, 2023

Copy link to clipboard

Copied

I have some confusion. When the object I select is a drawing object or shape, I can use the following code to add a stroke to it.

fl.getDocumentDOM().selection[0].x += 0;
fl.getDocumentDOM().setStrokeSize(10);

This code cannot take effect on the selected group or symbol.

Using the history function I get code like this:

an.getDocumentDOM().setStroke('#000000', 10, 'solid');

Repeated operations found that this code only takes effect on the drawing object union.

Back to my question:
If the selected object is a group or symbol, the following code cannot stroke it.

customStrokeWidth = 10; 
if (customStrokeWidth) {
  var doc = fl.getDocumentDOM();
  var selection = doc.selection[0];
  myStroke(selection, customStrokeWidth);
}
function  myStroke(element, strokeWidth) {
  if (element.elementType === "group") {
    var elements = element.getElements();
    for (var i = 0; i < elements.length; i++) {
      var nestedElement = elements[i];
      myStroke(nestedElement, strokeWidth);
    }
  } else {
    doc.selection = [element];
    doc.setStrokeSize(strokeWidth);
  }
}​

Did I miss something?

TOPICS
Code

Views

114

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 1 Correct answer

Engaged , Sep 23, 2023 Sep 23, 2023

Yes, the setStrokeSize() method sets the stroke size of the selected object,
but only if the object is either a raw shape or a union.

Symbols, on the other hand, cannot have their strokes directly modified since they are not raw shapes. To achieve this, you must enter to the symbol's timeline via the method enterEditMode() and iterate through its objects, adjusting their stroke sizes individually.

Similarly, modifying the stroke of a group is not possible because groups are not raw shapes or unions

...

Votes

Translate

Translate
Engaged ,
Sep 23, 2023 Sep 23, 2023

Copy link to clipboard

Copied

Yes, the setStrokeSize() method sets the stroke size of the selected object,
but only if the object is either a raw shape or a union.

Symbols, on the other hand, cannot have their strokes directly modified since they are not raw shapes. To achieve this, you must enter to the symbol's timeline via the method enterEditMode() and iterate through its objects, adjusting their stroke sizes individually.

Similarly, modifying the stroke of a group is not possible because groups are not raw shapes or unions.
Unfortunately, you cannot access their timeline for adjustments since it does not exist for groups.


- 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
Participant ,
Sep 23, 2023 Sep 23, 2023

Copy link to clipboard

Copied

I see, this is really a headache. In my recent project, I needed to add strokes to a lot of materials without strokes, so I thought of this.

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 ,
Sep 23, 2023 Sep 23, 2023

Copy link to clipboard

Copied

LATEST

it's just more coding and if you really have a lot of things to edit can still be very efficient.

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