Using images in dropdown menu options

CSD 22-23 Unit 6 Lesson 8 Bubble 8 : room background images and pet images
Could I get some information about using images? How do I add an image png or jpeg as an “asset” so that it will work as a choice on a dropdown menu? I’ve been able to add an “image address” in setProperty but this requires an “if” for each choice on the dropdown. This Level makes me think that “Save Image” and using the image file would work better.

@koliner,

Hopefully, I understand your questions. When you add an image element to the page, there is some blue text next to the property field in the design mode that says “choose”. when you click this, you can upload multiple images (even if you leave the property blank as you do on this assignment).

If you follow the comment codes on the page and assign a variable to each dropdown option, you can then use that variable to assign the image… here’s some example code:

onEvent("createButton", "click", function() {
  //1) Get the values from the dropdowns and store it in two variables
  var x = getText("backgroundDropdown");
  var y = getText("petDropdown");

  //2) Update the images on the screen
  setImageURL("backgroundimage", x);
  setImageURL("petImage", y);
});

The only other issue I saw is that the options should just be the image names (not the. “image://” in front of it.

I’m not quite sure what you mean by. “save image”. and using the image file, though. Let me know if this helps at all.

Mike