This UI script breaks after the first click..

I’ve been working on a script with some buttons in the UI, and I’ve found that for some reason after the first time clicking it, the button stops working if I’m using frame.current() anywhere in the function that’s getting executed.

I’ve created a simple version of the script to demonstrate the issue (ButtonUI.js). Note: it uses a ui file to lay out the gui (ButtonUI.ui).

Place both in your scripts directory, and execute.

A window will pop up with a button.

Click it once, and the current frame will output to the message log. Click a second time… nothing.
Replace frame.current() with “5” or something like that, and it works consistently.

Here are the files on github:

Hi !

Simply don’t declare the variable inside the anonymous function and directly MessageLog the “frame.current()”

MessageLog.trace("Current Frame: " + frame.current());

… and it works like a charm.

Hope it helps.


Huh - that didn’t work for me, unfortunately :frowning:

Are you trying in 16 or 15?

Oh man… I caught the error.

Stupid. :slight_smile:

I was using “frame” as a variable, and it’s also a class. ugh.

so instead of doing:

frame = frame.current();

I do

myFrame = frame.current();

and it works perfectly. durf. :slight_smile:


That’s what I meant yeah.

By the way I’m working on Harmony 16.

Good to know it’s fixed.