• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Slideshow 2 - call method in applescript
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Slideshow 2 - call method in applescript


  • Subject: Slideshow 2 - call method in applescript
  • From: peter <email@hidden>
  • Date: Wed, 23 Jul 2003 12:33:03 +0200

I recently posted a request for help on creating a slideshow with
applescript/Cocoa
thanks to all who gave me suggestions.

I am now using some applescript example code which seems to work pretty
well, the code successfully displays a slideshow of all the images in
my application bundle, like this:

property imagePaths : {}
property imageCount : 0
property imageIndex : 0
property theFolder : ""


on launched theObject
set theFolder to main bundle

-- Get the path to all of the tiff images in the application
set imagePaths to call method "pathsForResourcesOfType:inDirectory:"
of theFolder with parameters {"tif", ""}
try
set imageCount to count of imagePaths
log imageCount
end try
end launched


on idle theObject
-- If we have some images
if imageCount > 0 then
-- Only load an image if this is the first,
-- or if we have more than one to cycle through.
if (imageCount > 1) or (imageIndex is equal to 0) then
-- Adjust the count
set imageIndex to imageIndex + 1
if imageIndex > imageCount then
set imageIndex to 1
end if
-- Load the new image
set newImage to load image (item imageIndex of imagePaths)
-- Get a reference to the old image, if there is one
set oldImage to image of image view "image" of window "main"
-- Set the new image
set image of image view "image" of window "main" to newImage
-- Delete the old image (use try block in case no image)
try
delete oldImage
end try
end if
end if
-- Return 3 to call idle routine again in 3 seconds.
return 3
end idle

Now I have added a open panel in my app to change the source of the
slideshow to a different directory that is not in my application
bundle:

on panel ended theObject with result withResult
if withResult is 1 then
set theFolder to (path names of open panel as list)
end if
--set imagePaths to (path names of theFolder)
set imagePaths to call method "pathsForResourcesOfType:inDirectory:"
of theFolder with parameters {"tif", ""} try
set imageCount to count of imagePaths
log imageCount
end try


end panel ended

The previous call method is not suitable in this case. Please could
anyone suggest which method (from NSFileManager?, NSFilewrapper?) that
I should be using?


many thanks

Peter
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: Bug reports and documentation updates
  • Next by Date: Re: Bug reports and documentation updates (was Re: Subclassing NSPort (or NSSocketPort))
  • Previous by thread: Axes and Bezierpath Line width
  • Next by thread: Bindings , NSArrayController and NSTableView
  • Index(es):
    • Date
    • Thread