0
我試圖創建一個函數來創建一個按鈕(這樣保持「乾淨」的代碼)。功能來創建按鈕
下面是代碼:
(
Window.closeAll;
~w = Window.new(
name: "Xylophone",
resizable: true,
border: true,
server: s,
scroll: false);
~w.alwaysOnTop = true;
/**
* Function that creates a button.
*/
createButtonFunc = {
|
l = 20, t = 20, w = 40, h = 190, // button position
nameNote = "note", // button name
freqs // frequency to play
|
Button(
parent: ~w, // the parent view
bounds: Rect(left: l, top: t, width: w, height: h)
)
.states_([[nameNote, Color.black, Color.fromHexString("#FF0000")]])
.action_({Synth("xyl", [\freqs, freqs])});
}
)
(
SynthDef("xyl", {
|
out = 0, // the index of the bus to write out to
freqs = #[410], // array of filter frequencies
rings = #[0.8] // array of 60 dB decay times in seconds for the filters
|
...
)
的錯誤是:ERROR:變量 'createButtonFunc' 沒有定義。 爲什麼?
很抱歉,但我是個初學者。
謝謝!