Preload images

Hi there,

I’ve made an apple-script application in xcode. Now I’d like to change the image of a button (interface builder), it works fine, but the time to load these images is very long.


on clicked theObject
	
	set imagePath1 to "acrobat.png"
	set helpImage1 to load image imagePath1
	
	set imagePath2 to "distiller.png"
	set helpImage2 to load image imagePath2
	
	delay 2
	
	if name of theObject is "start_button" then
		
		set image of theObject to helpImage1
		
		tell application "Finder"
			
			--  ¢ AUSGEWÄHLTE DATEIEN ÃœBERPRÃœFEN
			set theSel to selection
			set theSelT to theSel as text
			
			set theCount to count every item of theSel
					
		end tell
		
		end clicked


Is there en possibility to preload the images before?

Thanks for your help!

Cheers
Marth

This is not ApplescriptObjC you’re asking but Applescript-Studio, it is possible.

The loading takes much times because you build a delay of two seconds in it.

To do a pre load in your programm make a property in your script, then go to the mainMenuNib and click on file owner and activate laucned handler then

property helpImage1 : missing value
property helpImage2 : missing value

on launched theObject
   set helpImage1 to load image "acrobat.png"
   set helpImage2 to load image "distiller.png"
end launched

on clicked theObject
 if name of theObject is "start_button" then
       
       set image of theObject to helpImage1
       
       tell application "Finder"
           
           -- ¢ AUSGEWÄHLTE DATEIEN ÃœBERPRÃœFEN
           set theSel to selection
           set theSelT to theSel as text
           
           set theCount to count every item of theSel
                   
       end tell
end clicked

If you want this image to appear when the program starts up, why do it in code at all? Just drag your image files into the the Resources folder (actually, any of the folders will work) of the Groups & Files pane of the xcode window, and then in IB, these image files will show up in the pull down menu next to the Image and Alt. Image choosers of your button in the inspector. Choose your image from the list, and then set the scaling you want with the Scaling property chooser that’s just below the Alt. Image chooser.

Ric