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

How to obtain the coordinates of mouse clicks on stage in JSFL?

New Here ,
Jan 29, 2024 Jan 29, 2024

Copy link to clipboard

Copied

I have rewritten these two methods in the jsx file without any effect

 

function mouseDown() {
    fl.trace("Mouse button has been pressed");
}
function mouseDown(pt) {
    fl.trace("x = "+ pt.x+" :: y = "+pt.y);
}

 

This method may also report errors

 

 fl.addEventListener("mouseDown", myFunction);

 

Thank you very much if you can!

 
TOPICS
Code

Views

628

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

Community Expert , Jan 29, 2024 Jan 29, 2024

Hi.

 

These methods are for extensible tools: activate(), configureTool(), deactivate(), keyDown(), keyUp(), mouseDoubleClick(), mouseDown(), mouseMove(), mouseUp(), notifySettingsChanged(), and setCursor().

 

The PolyStar tool uses the structure/code of an extensible tool. You can find it in:

<ADOBE_ANIMATE_INSTALL_FOLDER>/<LANGUAGE>/First Run/Tools

 

Regards,

JC

 

 

 

 

Votes

Translate

Translate
Engaged , Jan 30, 2024 Jan 30, 2024

If you want to implement shape creation with JSFL, I recommend examining the script PolyStar.jsfl located in the Tools subfolder. It demonstrates the correct usage of mouseDown(), mouseUp(), and mouseMove().

I advise against subscribing to the mouseMove event. While technically possible, I believe it is not a good practice. I have seen panels that degrade the overall program performance because they subscribed to computationally intensive functions on mouseMove.

If you want to incorporate drawing

...

Votes

Translate

Translate
Community Expert ,
Jan 29, 2024 Jan 29, 2024

Copy link to clipboard

Copied

no such event for fl.  check the api.

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
New Here ,
Jan 29, 2024 Jan 29, 2024

Copy link to clipboard

Copied

Thank you for your answer,this method is used in the API, but I don't know how to use it

 

function mouseDown() {
    fl.trace("Mouse button has been pressed");
}
function mouseDown(pt) {
    fl.trace("x = "+ pt.x+" :: y = "+pt.y);
}

 

link:https://github.com/AdobeDocs/developers-animatesdk-docs/blob/master/JSAPI.md 

 

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 ,
Jan 29, 2024 Jan 29, 2024

Copy link to clipboard

Copied

fl has that method, but not that event.  further there is no jsfl object that has that method and event.  ie, use an on-stage object.

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
New Here ,
Jan 29, 2024 Jan 29, 2024

Copy link to clipboard

Copied

Thank you, got it.  another problem, this event is ok, with log output

function onMove() {
  fl.removeEventListener("mouseMove", myFunction)
}

function myFunction() {
  fl.trace("move");
}

But this is not output log 

function myFunction(pt) {
  fl.trace("x = " + pt.x + " :: y = " + pt.y);
}

I see that the API has this method, may I ask how to write it, Thank you again

link:https://github.com/AdobeDocs/developers-animatesdk-docs/blob/master/Top-Level_Functions_and_Methods/... 

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 ,
Jan 29, 2024 Jan 29, 2024

Copy link to clipboard

Copied

myFunctions argument is the event, not a point, assuming you're using a mousemove event listener 

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
New Here ,
Jan 29, 2024 Jan 29, 2024

Copy link to clipboard

Copied

Sorry, I made a mistake in copying, It should be this code

fl.addEventListener("mouseMove", myFunction);

I changed it to event

function myFunction(event) {
  fl.trace(event);
}

but log print  undefined

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 ,
Jan 29, 2024 Jan 29, 2024

Copy link to clipboard

Copied

this code worked for me 

 

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 ,
Jan 29, 2024 Jan 29, 2024

Copy link to clipboard

Copied

Hi.

 

These methods are for extensible tools: activate(), configureTool(), deactivate(), keyDown(), keyUp(), mouseDoubleClick(), mouseDown(), mouseMove(), mouseUp(), notifySettingsChanged(), and setCursor().

 

The PolyStar tool uses the structure/code of an extensible tool. You can find it in:

<ADOBE_ANIMATE_INSTALL_FOLDER>/<LANGUAGE>/First Run/Tools

 

Regards,

JC

 

 

 

 

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
New Here ,
Jan 29, 2024 Jan 29, 2024

Copy link to clipboard

Copied

got it, this means that I cannot add these events in my customized panel, but need to use the add extension tool to achieve

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 ,
Jan 29, 2024 Jan 29, 2024

Copy link to clipboard

Copied

Using an extensible tool is probably the best way to track the cursor position. Listening to the "mouseMove" event is also possible, although I think it's kinda tricky to use it.

 

But what exactly do you need to do?

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
New Here ,
Jan 29, 2024 Jan 29, 2024

Copy link to clipboard

Copied

I want to quickly draw a circle between two points, so I need two coordinates to calculate, such as quickly drawing a green circle that can be tangent to two pointsoval.png

 

 

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
Engaged ,
Jan 30, 2024 Jan 30, 2024

Copy link to clipboard

Copied

If you want to implement shape creation with JSFL, I recommend examining the script PolyStar.jsfl located in the Tools subfolder. It demonstrates the correct usage of mouseDown(), mouseUp(), and mouseMove().

I advise against subscribing to the mouseMove event. While technically possible, I believe it is not a good practice. I have seen panels that degrade the overall program performance because they subscribed to computationally intensive functions on mouseMove.

If you want to incorporate drawing as a functionality in your panel, write it as a tool script, and then integrate it appropriately in the panel using:

 

MMExecute( "fl.selectTool( 'yourCustomToolName' );" );

 



 

- 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
New Here ,
Jan 30, 2024 Jan 30, 2024

Copy link to clipboard

Copied

LATEST

Thank you very much, I will follow this idea

 

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