Funky icon issue on display dialog

Hello,
Knowing that:

  1. I am a noob
  2. I have not used illegal drugs in a while
  3. I have not overindulged in alcohol for a long time

I was trying to use an Apple icon in the script (system profiler icon) ASP.icns, and each time the icon disappear when the script is saved as an .app and when run as an app, the error Can’t Find … shows up.
Compiled Test Run as a script, everything is fine. Saved as an app, not fine!

But, when I use an icon that I made myself, it works. Does anybody has a rational explanation? because right now, my most logical thought is Apple Voodoo.

Working Example:

set answer to button returned of (display dialog " foobar" with icon alias ((path to me) & ":foobar.app:Contents:Resources:icns:My.icns" as string) with title "FOOBAR" buttons {"Cancel", "Option 1", "Option 2"} default button 2)

NON working example
the sole change is in “ASP.icns”

set answer to button returned of (display dialog " foobar" with icon alias ((path to me) & ":foobar.app:Contents:Resources:icns:ASP.icns" as string) with title "FOOBAR" buttons {"Cancel", "Option 1", "Option 2"} default button 2)

Thanks in advance

Hi,

path to me could be interpreted in a different way, when you run the script from Script Editor or as stand-alone app (it depends on the AppleScript and system version).

Nevertheless your syntax is a bit weird.
Assuming that the icon is in Contents/Resources/icns of the applescript app, the syntax is like this

set answer to button returned of (display dialog " foobar" with icon alias ((path to me as text) & "Contents:Resources:icns:My.icns") with title "FOOBAR" buttons {"Cancel", "Option 1", "Option 2"} default button 2)

In a stand-alone script/app path to me points always to the script/app file

Hi Stefan,
Thanks for the prompt reply.

“Nevertheless your syntax is a bit weird”
I warned you: I am a noob… but thanks a lot for the correction & explanation.