Can't figure out why this doesn't work right
Posted: October 9th, 2013, 3:13 pm
Hi, I'm doing a video tutorial series from FXPHD on AEscripting and I've hit a brickwall. I've typed exactly what they have, but for some reason this isn't working right.
var myWindow = new Window ("dialog", "My Window");
myWindow.okButton = myWindow.add("button");
myWindow.okButton.text = "OK"
myWindow.cancelButton = myWindow.add("button");
myWindow.cancelButton.text = "Cancel"
myWindow.show();
myWindow.okButton.onClick = function() {
alert("OK");
myWindow.close();
};
myWindow.cancelButton.onClick = function() {
alert("Cancel");
myWindow.close();
};
2 things I've noticed when I run it is that it will show the window, but if you click on a button it won't do anything as if it won't let me run inline functions. If I turn those into 2 regular functions and define them after the onClick statements, then what happens is that when you click on one button, both alerts pop up as if it's running one function after another.
I know this is probably a silly question, but i'm at the start of this video and can't move on without finding out why it's acting this way. thank you guys.
var myWindow = new Window ("dialog", "My Window");
myWindow.okButton = myWindow.add("button");
myWindow.okButton.text = "OK"
myWindow.cancelButton = myWindow.add("button");
myWindow.cancelButton.text = "Cancel"
myWindow.show();
myWindow.okButton.onClick = function() {
alert("OK");
myWindow.close();
};
myWindow.cancelButton.onClick = function() {
alert("Cancel");
myWindow.close();
};
2 things I've noticed when I run it is that it will show the window, but if you click on a button it won't do anything as if it won't let me run inline functions. If I turn those into 2 regular functions and define them after the onClick statements, then what happens is that when you click on one button, both alerts pop up as if it's running one function after another.
I know this is probably a silly question, but i'm at the start of this video and can't move on without finding out why it's acting this way. thank you guys.