Making buttons perform functions

All things .jsx

Moderator: Paul Tuersley

Post Reply
maximumrfan
Posts: 8
Joined: September 16th, 2010, 8:13 pm

I have been making scripts for about 2 weeks, and I have created a script that simply makes a camera rig, and I decided to add a user interface to it so that it looks a little bit more professional. I have been wrestling JavaScript for 2 hours straight, and I can't get the button to do ANYTHING. I have looked at others scripts to see what they did (AE3D Exporter, SkyDome, ect.) and I am still stumped. I have my script up on my Opera Unite server if you want to download it and tell me what I'm doing wrong.
http://secretnetworkc2c.maximumrfan.ope ... e_sharing/
It will be "MRFCameraRig _ User Interface.jsx".
Thanks,
Matthew
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

I couldn't access your script, but generally, after defining your UI you would include code like this to call a function when the button is clicked:

Code: Select all

pal.grp.mid.left.preset.deleteButton.onClick = onDeletePresetButton;
Don't put () after the function name or it'll get called when initially defined. Or if you want to create a new specific function for it you could use code like:

Code: Select all

pal.grp.top.progBarBut.buttons.about.onClick = function() {
	if (helpWindow instanceof Window) helpWindow.show();
	else helpWindow();
}
Check out the "Control event-handling callbacks" section of the Javascript Tools Guide pdf.
maximumrfan
Posts: 8
Joined: September 16th, 2010, 8:13 pm

Paul Tuersley wrote:I couldn't access your script, but generally, after defining your UI you would include code like this to call a function when the button is clicked:

Code: Select all

pal.grp.mid.left.preset.deleteButton.onClick = onDeletePresetButton;
Don't put () after the function name or it'll get called when initially defined. Or if you want to create a new specific function for it you could use code like:

Code: Select all

pal.grp.top.progBarBut.buttons.about.onClick = function() {
	if (helpWindow instanceof Window) helpWindow.show();
	else helpWindow();
}
Check out the "Control event-handling callbacks" section of the Javascript Tools Guide pdf.
Thank you! I finally figured out what I was doing wrong. I uploaded the script I made to MegaUpload.
http://www.megaupload.com/?d=3SVNF4F4
P.S. It's in alpha/beta/whatever-you-call-it phase.
Thanks,
Matthew
Post Reply