Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Scoping issue, seeking enlightenment



Ooops, sorry, reverse the first two lines, declare properties and globals first.



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

set freezeAd to false

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

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Studio mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-studio/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.