5 Replies Latest reply on May 29, 2009 6:20 AM by Ned Murphy

    Image Selection Based on Criteria and Filename

    Apoc198

      Thank you in advance for your time.

       

      Here is what I'm trying to do.  I have a sunroom product that is available with several different options.  I have created images of every possible combination of options, and named the files like this:

       

      DeckFurniture_NoVisor_ClearGlass_View1.jpg

       

      DeckFurniture_NoVisor_Clear_View10000.jpg

       

      Hot Tub_Visor_TintedGlass_View3.jpg

       

      HotTub_YesVisor_Tinted_View30000.jpg

       

       

      I want users to be able to choose their options, and have the appropriate picture be displayed.  So to get the above image, they'd have to choose "Deck Furniture" "No Visor" "Clear Glass" and "View 1".  Or to get the other one they'd choose "Hot Tub" "Yes Visor" "Tinted Glass" and "View 3"

       

      Does anyone know of a tutorial that would help me accomplish this?  It's not necessary to have it auto-update the image, so I was thinking they could choose their options and then click "Update", and that would in a sense pull up the correct filename from the options they've chosen.  I'm not exactly sure how to tell Flash to change this master variable (the filename) whenever one of the sub-variables (pieces in the filename) change.  Would I have to put a script on each option button telling it when it gets selected to change the master variable?

       

      Best Regards and thanks again!

        • 1. Re: Image Selection Based on Criteria and Filename
          Ned Murphy Adobe Community Professional & MVP

          If you give your images consistent names, meaning four parts each, then you could build the image name from the user selections.  The actual names could use abbreviations or full words as you have done.  How you build those depends on what you provide for the user to make the selections.

           

          Once you have the image name defined, you could use the MovieClipLoader class (or loadMovie if you don't care about indicating a loading with status) to load the image and place it into a movieclip on the stage.

          • 2. Re: Image Selection Based on Criteria and Filename
            Apoc198 Level 1

            That's exactly what I want to do.  The user will be given radio buttons for each possible option.  They will be able to choose either Deck Furniture or a Hot Tub as the background, Visor or No Visor, Clear or Tinted Glass, and Views 1, 2, and 3.

             

            I want to do just what you said, where when they click the radio buttons to choose their options, and then click the "Update Image" button, it will load the filename that is comprised of all of their options.  How would I go about saying, if they click this radio button, the first part of the file name will be this, but if they click this one it will be this instead?

             

            All the Update Image button should do is load whatever filename the radio buttons throw to it, but I don't know how to construct/assemble this file name into one name for the Update Image button.

             

            Thanks for the very prompt reply.

            • 3. Re: Image Selection Based on Criteria and Filename
              Ned Murphy Adobe Community Professional & MVP

              You will build a function for that button that collects the value associated with each checked radio button and builds a string from them.  Right at the moment I have html radio buttons on my mind, so I'll have to visit the help docs to see what goes on with reading Flash radios.

               

              Here's a shorthand version of the function...

               

              showImgBtn.onRelease = function (){

                   var imageName:String = "";

                   imageName += (radioGroup1.selection.data+"_");

                   imageName += (radioGroup2.selection.data+"_");

                   imageName += (radioGroup3.selection.data+"_");

                   imageName += (radioGroup4.selection.data+".jpg");

                   imageMC.loadMovie(imageName);

              }

               

              Note: imageMC would be any empty movieclip that is located as the upper left corner of your image display area

               

              As I said, I need to refresh my brain on the radio buttons, but you could look them up in the help docs (or Google "AS2 RadioButton") and see what is needed to deal with them.  Also, I took the shortcut and used loadMovie, but using the MovieClipLoader class provides more utility if you need/prefer that.

               

              Update: I revised the radio button code in the function above to what might work.  It'd have to be tested to confirm whether I hit it or missed it.

              1 person found this helpful
              • 4. Re: Image Selection Based on Criteria and Filename
                Apoc198 Level 1

                Thanks a lot, I'm going to give this a shot and get back to you with what I find out.  I really appreciate it!

                • 5. Re: Image Selection Based on Criteria and Filename
                  Ned Murphy Adobe Community Professional & MVP

                  You're welcome.  If you run into any snags, just ask.