Skip to main content
Participating Frequently
January 29, 2024
Answered

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

  • January 29, 2024
  • 3 replies
  • 1461 views

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!

 
This topic has been closed for replies.
Correct answer Vladin M. Mitov

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' );" );

 



 

3 replies

Vladin M. Mitov
Vladin M. MitovCorrect answer
Inspiring
January 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 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 1998Member of Flanimate Power Tools team - extensions for character animation
Participating Frequently
January 30, 2024

Thank you very much, I will follow this idea

 
JoãoCésar17023019
Community Expert
Community Expert
January 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

 

 

 

 

Participating Frequently
January 29, 2024

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

JoãoCésar17023019
Community Expert
Community Expert
January 29, 2024

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?

kglad
Community Expert
Community Expert
January 29, 2024

no such event for fl.  check the api.

Participating Frequently
January 29, 2024

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 

 
kglad
Community Expert
Community Expert
January 29, 2024

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.