Images in Media Library

Hello,

3 images into the project: green.png, orange.png, and red.png (bullets).

In applicationWillFinishLaunching:

        set greenBulletPath to (current application's NSBundle's mainBundle()'s pathForResource_ofType_("green", "png") as string)
        set greenBullet to NSImage's alloc()'s initWithContentsOfFile_(greenBulletPath)
        
        set orangeBulletPath to (current application's NSBundle's mainBundle()'s pathForResource_ofType_("orange", "png") as string)
        set orangeBullet to NSImage's alloc()'s initWithContentsOfFile_(orangeBulletPath)
        
        set redBulletPath to (current application's NSBundle's mainBundle()'s pathForResource_ofType_("red", "png") as string)
        set redBullet to NSImage's alloc()'s initWithContentsOfFile_(redBulletPath)

For display the red image, for example:

         myImageView's setImage_(redBullet)

I see there are already similar images in the Media Library named: NSStatusAvailable, NSStatusPartiallyAvailable, and NSStatusUnavailable but I don’t know how use them… Is it possible? :confused:

Thanks!

For your first examples, all you need is:

set anImage to current application's NSImage's imageNamed:"green"

As long as it’s in Resources, it will be found.

But what you’re after is:

set anImage to current application's NSImage's imageNamed:"NSStatusAvailable"
set anImage to current application's NSImage's imageNamed:"green" 

Thanks a lot Shane!! It works…

Strange behavior. When I deleted the green, red, and orange images, the NSStatusAvailable, NSStatusPartiallyAvailable, and NSStatusUnavailable are also deleted in the Media Library. Probably the same objects. :confused:
Then I reload the green, red, and orange images into the project and it’s OK now.

:cool: