Expressions/Scripts/Presets

Moderator: Paul Tuersley

 
maximumrfan
Topic Author
Posts: 8
Joined: Thu Sep 16, 2010 8:13 pm

Making buttons perform functions

Mon Sep 20, 2010 3:29 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: Sat Jun 05, 2004 7:59 am
Location: London, UK

Re: Making buttons perform functions

Tue Sep 21, 2010 3:41 am

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:
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:
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
Topic Author
Posts: 8
Joined: Thu Sep 16, 2010 8:13 pm

Re: Making buttons perform functions

Tue Sep 21, 2010 1:14 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:
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:
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

Who is online

Users browsing this forum: No registered users and 2 guests