G'day Troy
Only set the globals at the start of the script, once
On 16/05/2008, at 12:55 AM, Troy Davis wrote:
Hello everyone,
I'm new to Applescript Studio, but I've used Applescript in small ways for 10+ years. I'm currently working on a small app that has an ad banner in it, by default it rotates every minute to a new banner. What I'm having trouble with is getting the banner to stop rotating while the user hovers over it. After reading about scoping options ( http://snipurl.com/28z3m ), I think I should be declaring the variable like so in my Document.applescript:
global freezeAd on idle theObject try set tmpFreeze to freezeAd on error set freezeAd to false end try display dialog "freezeAd in idle handler: " & freezeAd if freezeAd is equal to false then -- code to rotate banner end if return 1 end idle
on mouse entered theObject event theEvent if the name of theObject is equal to "bottomWebViewButton" then set freezeAd to true display dialog "Entered banner, freezeAd is " & freezeAd end if end mouse entered
on mouse exited theObject event theEvent if the name of theObject is equal to "bottomWebViewButton" then set freezeAd to false display dialog "Exited banner, freezeAd is " & freezeAd end if end mouse exited
I've got the mouse entered and mouse exited handlers setup in IB, I can display a dialog upon entering or exiting the ad banner's space successfully. But the banner keeps rotating, somehow freezeAd gets reset to false in the on idle handler. But if I'm reading the Apple docs correctly, this is the recommended way to declare a variable for the whole script and access it within handlers.
Can anyone point me in the right direction?
Thank You, Troy
|