fpbspades
07-06-2010, 11:23 PM
I'm trying to understand how to use Applescript to command NSImageview objects, specifically to load images into them. I'm using Xcode 3.1.4 on OSX 10.5.8 .
I'm working off of the "Image" Example from the Applescript Studio example programs. When I build the program it functions normally. But when I try to expand the code in Application.applescript from
on awake from nib theObject
set image of image view "image" of window "main" to load image "AboutBox"
end awake from nib
to my own code (where "s1", "s2", etc are the names of image files that I have added to the Resources folder of my project):
on awake from nib theObject
set dummyvariable to some item of {"s1", " s2", "s3", "s4"}
set image of image view "image" of window "main" to load image dummyvariable
end awake from nib
sometimes when I hit build and go, the image loads and everything is fine but other times (about one in three), but more consistently if I dont rebuild it but just run the program, I get an error:
AppleScript Error
Can't make current application into type <<class imaA>>. (-1700)
So, what could be causing this error (that only happens sometimes) and what would be a fix?
Also, I am curious what is <<class imaA>> (and for that matter <<class imaV>>, I got a -1700 error saying i couldn't make one class into the other, etc. in other attempts to get NSImageview objects to load image files)? My internet searching didn't come up with anything helpful about those classes.
FYI: I'm trying to teach myself coding with this project, so any and all help is appreciated. Thanks very much.
-fpbspades
I'm working off of the "Image" Example from the Applescript Studio example programs. When I build the program it functions normally. But when I try to expand the code in Application.applescript from
on awake from nib theObject
set image of image view "image" of window "main" to load image "AboutBox"
end awake from nib
to my own code (where "s1", "s2", etc are the names of image files that I have added to the Resources folder of my project):
on awake from nib theObject
set dummyvariable to some item of {"s1", " s2", "s3", "s4"}
set image of image view "image" of window "main" to load image dummyvariable
end awake from nib
sometimes when I hit build and go, the image loads and everything is fine but other times (about one in three), but more consistently if I dont rebuild it but just run the program, I get an error:
AppleScript Error
Can't make current application into type <<class imaA>>. (-1700)
So, what could be causing this error (that only happens sometimes) and what would be a fix?
Also, I am curious what is <<class imaA>> (and for that matter <<class imaV>>, I got a -1700 error saying i couldn't make one class into the other, etc. in other attempts to get NSImageview objects to load image files)? My internet searching didn't come up with anything helpful about those classes.
FYI: I'm trying to teach myself coding with this project, so any and all help is appreciated. Thanks very much.
-fpbspades