Skip to main content
Participating Frequently
Jan 29, 2024 4:37 PM UTC
Answered

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

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 is closed to new replies. Start a new post to keep the conversation going.
Vladin M. Mitov
Vladin M. MitovCorrect answer
Inspiring
Jan 30, 2024 8:53 AM UTC

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

13 replies

Vladin M. Mitov
Vladin M. MitovCorrect answer
Inspiring
Jan 30, 2024 8:53 AM UTC

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

 



 

Translate
- Vlad: UX and graphic design, Flash user since 1998Member of Flanimate Power Tools team - extensions for character animation
Participating Frequently
Jan 30, 2024 3:35 PM UTC

Thank you very much, I will follow this idea

 
Translate
JoãoCésar17023019
Community Expert
Community Expert
Jan 29, 2024 6:31 PM UTC

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

 

 

 

 

Translate
Participating Frequently
Jan 29, 2024 7:37 PM UTC

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

Translate
JoãoCésar17023019
Community Expert
Community Expert
Jan 29, 2024 9:39 PM UTC

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?

Translate
kglad
Community Expert
Community Expert
Jan 29, 2024 4:47 PM UTC

no such event for fl.  check the api.

Translate
Participating Frequently
Jan 29, 2024 4:50 PM UTC

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 

 
Translate
kglad
Community Expert
Community Expert
Jan 29, 2024 5:01 PM UTC

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.

Translate