Switching Images and {PROJECT_FOLDER}
-
Hello friends.
I've got a comboBox with about six items. The items are connected to the sample-maps and to a script image. OnControl, the comboBox is supposed to load the desired instrument/sample-map along with it's matching icon image. (Some code below)
I'm using mostly stuff in Mr. Healey's tutorials. It works to an extent. The sample maps change fine and the instrument name is sent to the image's fileName, but the image box still says "missing". I think it has something to do with the {PROJECT_FOLDER} wild card, but I haven't been able to figure it out.
I think it would work if I could set the comboBox to include the wildcard string along with the value sent to the the image fileName. I just don't know how.
Any suggestions?
Gracias.// INSTRUMENTS COMBO BOX const var sampleMaps = Sampler.getSampleMapList(); const var cmbInstruments = Content.getComponent("cmbInstruments"); cmbInstruments.set("items", sampleMaps.join("\n")); // const var wildcardPlus = {w:"{PROJECT_FOLDER}", i:instrumentName}; inline function oncmbInstrumentsControl(component, value) { var instrumentName = (sampleMaps[value-1]); Sampler1.asSampler().loadSampleMap(sampleMaps[value-1]); Engine.loadImageIntoPool(instrumentName); iconImage.set("fileName", instrumentName); Console.print(instrumentName); }; Content.getComponent("cmbInstruments").setControlCallback(oncmbInstrumentsControl);
-
@RastaChess
Use
local
instead ofvar
in inline functions.Load all your images into the pool in
on init
instead of in your function. This is an operation that only needs to be done once when the project loads so there is no need to do it every time the combo box callback triggers.Engine.loadImageIntoPool("{PROJECT_FOLDER}imageName.jpg");
is probably the format you need. If the images are in subfolders you need to include that. -
@d-healey Thanks for your reply.
I incorporated your suggestions. Thanks. They work fine, but I'm still having the issue with the images not being found.
The local variable "instrumentName" contains/sends the file-name to the image but without the "{PROJECT_FOLDER}". So it shows up in the property editor as just the name, not "wildcard+imageName" which is what is needed, I think.Is there a way to add the wildcard to the "instrumentName" as part of the value being sent to the imageFile.?
Note: images (PNG) are inside the images folder of the project, no subfolders and apear to be loading into the pool just fine.
Help is much appreciated.
Thank you.Updated code.
// INSTRUMENTS COMBO BOX const var sampleMaps = Sampler.getSampleMapList(); const var cmbInstruments = Content.getComponent("cmbInstruments"); cmbInstruments.set("items", sampleMaps.join("\n")); inline function oncmbInstrumentsControl(component, value) { local instrumentName = (sampleMaps[value-1]); Sampler1.asSampler().loadSampleMap(sampleMaps[value-1]); iconImage.setImageFile(instrumentName, 0); Console.print(imageFile); Console.print(instrumentName); }
-
@RastaChess
Try
iconImage.setImageFile("{PROJECT_FOLDER}" + instrumentName + ".png");
-
YES!!
That works.
Thank you sooooo much!
:folded_hands_light_skin_tone:Best Regards.