I’m in the middle of creating my first AS application. I’m creating an app to manage timers in Audio Hijack Pro. My application works like I want up to this point. The only problem I’m having is when I launch the application, I see the main window at the left part of my screen momentarily and then it disappears and moves to the center of the screen. I’m very new to scripting, so I don’t know if this is normal for AS. Any help would be greatly appreciated. Here’s my code:
on awake from nib theObject
if theObject = "main" then
set visible of theObject to true
tell theObject
set content of control "record_date_time" to (current date)
end tell
end if
end awake from nib
on clicked theObject
tell window "main"
set recording_option_list to {}
if the name of theObject = "record_date_time" then
set record_time to (get content of control "record_date_time")
else if the name of theObject = "OK_Button" then
set recording_duration to ((the content of text field "record_duration") * 60) as string
set recording_time to (get content of control "record_date_time")
set theSession to title of key cell of matrix "XM_Station"
if state of button "option_record" is 1 then
set the end of recording_option_list to "record"
end if
if state of button "option_mute" is 1 then
set the end of recording_option_list to "mute"
end if
if state of button "option_quit_source" is 1 then
set the end of recording_option_list to "quit"
end if
tell application "Audio Hijack Pro"
try
set theSession to (first item of (every session whose name is theSession))
theSession is not null --Force an error if theSession doesn't exist
on error
--If the session isn't found, make a new one
set theSession to make new application session at end of sessions
set name of theSession to theSession
end try
tell theSession
--Set the session target to Safari
tell application "Finder"
set pathToSafari to (POSIX path of (path to application "Safari"))
end tell
set targeted application to pathToSafari
--Create a new timer
set theTimer to make new timer at end of timers
tell theTimer
--Turning off all the days forces a one-shot timer
set {runs Monday, runs Tuesday, runs Wednesday, runs Thursday, runs Friday, runs Saturday, runs Sunday} to {false, false, false, false, false, false, false}
--Really setup the timer
set start time to recording_time
set duration to recording_duration
set actions to recording_option_list
--Activate the timer in Audio Hijack Pro
set enabled to true
end tell
set recording format to {encoding:AAC, bit rate:128, channels:Stereo, style:Bookmarkable}
end tell
end tell
set the content of text field "record_duration" to ""
set the state of button "option_record" to 0
set the state of button "option_mute" to 0
set the state of button "option_quit_source" to 0
else if the name of theObject = "cancel_button" then
quit
end if
end tell
end clicked
Model: iMac G5
Browser: Safari 412.2
Operating System: Mac OS X (10.4)