Announcement

Collapse
No announcement yet.

Images visibility at same time

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Images visibility at same time

    Friends ( Beginner question )

    A have a button " A " that when cliked must make invisible Image_01, Image_02 and Image_03 at same time . Can anyone help me with this code lines ?

    Best

  • #2
    Really? Did you even bother to check the manual?



    Took about 4.2 seconds to find that one.
    Come on man, RTFM before posting help-requests like this.
    Code:
    Image.SetVisible("Image1", false);
    Image.SetVisible("Image2", false);
    Image.SetVisible("Image3", false);
    ...or read the section on using count-loops:
    Code:
    for count = 1, 3 do
        Image.SetVisible("Image"..count, false);
    end

    Comment


    • #3
      Hi BioHazard
      Thank you a lot for the help. The basics I grab from the manual, like ( Image.SetVisible("Image1", false); )
      but your " count-loops " code version is the one I was looking for . This is amazing. My only one question is .. when I rename the images, it seems not work . for instance.. image1 renamed is = sun_01 ! So, I may have a bunch of images with names : sun_01, sun_02,sun_03, sun_04,sun_05 .. ) and so on. I tried with your " count-loops code but wihtout success! Could you help me on this ? Image will always be renamed for something like ; name_01, name_02,name_03.... Best

      Comment


      • #4
        The count-loop is referencing the name of the ImageObjects, not the images themselves. So it doesn't matter what the images are named but it does matter what the ImageObjects are named.

        In the APZ example attached below, the images are named as:
        • imgA
        • imgB
        • imgC

        ...but this is unimportant and irrelevant to the functioning of the count-loop. Because the count-loop is referencing the ImageObjects, not the images. To demonstrate, in this particular example, I've renamed the ImageObjects from their default names of:
        • Image1
        • Image2
        • Image3

        to:
        • sun_01
        • sun_02
        • sun_03


        The code for the count-loop will now have to be adjusted accordingly. The key here, is in understanding the portion of code I've highlighted in red:
        Code:
        for count = 1, 3 do
            Image.SetVisible([COLOR=#FF0000]"sun_0"..count[/COLOR], false);
        end
        ...which breaks down like this:
        Code:
        [B]"sun_0"[/B][I][COLOR=#008000] -- this is the name of each ImageObject (minus its identifying number)[/COLOR][/I]
        [B]..[/B] [I][COLOR=#008000]-- this is the symbol for concatenating (joining) values[/COLOR][/I]
        [B]count[/B] [I][COLOR=#008000]-- this is the relative variable in which the identifying number is stored[/COLOR][/I]
        So, as it counts thru the loop from 1 to 3, it translates as:
        Code:
        sun_01
        sun_02
        sun_03
        ...which are the names of the ImageObjects we're instructing the count-loop to reference during execution. Now the code will work with the changed names you've allocated to the ImageObjects.
        Attached Files

        Comment


        • #5
          Hi BioHazard

          Thank you again for the amazing help. I got the whole poing on this , but due to some lack of information from my side, I just missed real code status. Assuming what you have explained before, I was able to reproduce and this worked hundred percent !! But, there is another small detail that I wasn't able to make work.

          if I have a range of images that are separated by a few images in the midle of the sequence that are not needed.. for example :

          I need to make visible :

          sun_01,sun_02,sun_03 ( sun_04 not needed ) sun_05,sun_06 ( sun_07 not needed ) sun_08


          this way , the sequence needed is ( sun_01_02_03 _05 _06 ) and the ones that should NOT be affected ( sun_04_07)

          Is there a way to control this inside the same count_loop ?

          hope to hear from you soon .

          Comment


          • #6
            First, let's re-establish that we're referencing Image Objects here, not the images. You seem to be conflating these concepts.

            Second, let's keep things as simple as possible. Unless you have a specific need to rename the Image Objects, (for the time being at least) let's leave them with their default names. (ie. Image1, Image2, Image3, etc)....

            So, you have 8 Image Objects, (each loaded with an image). Again, doesn't matter what the images are named. Call 'em: 'pink_elephant, purple_tiger, whatever. Doesn't matter.

            To exclude some of the images from being affected by the count-loop, you must instruct the count-loop to lay 'hands-off' the Image Objects in which these images are stored. You can do that in a number of slightly different ways. But one way would be to insert an if/then statement into the count-loop:

            ie. example syntax
            Code:
            if count ~= n then
            --do something here
            end
            So, for the scenario described above, you would code as:
            Code:
            for count = 1, 8 do [COLOR=#008000][I]-- Starting at 1, count to 8 (because we're referencing 8 Image Objects) and[/I][/COLOR]
            if count ~= 4 and count ~= 7 then [COLOR=#008000]-- if dynamic variable (count) does not equal 4 or 7 then[/COLOR]
                Image.SetVisible("Image"..count, false); [COLOR=#008000][I]-- proceed to set each Image Object invisible.[/I][/COLOR]
                end
            end
            Attached Files

            Comment


            • #7
              Hi Biohazard,, thank you a lot for the amazing solution. Code works perfect. My only limitation now is ,, the code ( for images with underline and numbers ex sun_09) only works up to 9 items ( single numbers ). If I have numbers higher than 09 , for any reason ,it doenst take effect. Ex 10 , 11, 12, 13 , 14 .....
              So , if I have more then 09 elements ( lets say 12 ) in the screen, numbers 10 , 11 , 12 will not take effect !

              lets use the example :

              sun_01 sun_02 sun_03.....................sun_12
              for count = 1, 12 do Image.SetVisible("sun_0"..count, false); end Only number from 01 up to 09 will take effect ! numbers from 10 to 12 will not take result !

              Can you help me with this ?

              Comment


              • #8
                sorry, message above was very unformated ( confusing ) ! I am attaching a sample. Take a look and you will understand the problem.
                Attached Files

                Comment


                • #9
                  You're concatenating "sun_0" with 1 thru 12 right?
                  Which translates as:
                  Code:
                  sun_01
                  sun_02
                  sun_03
                  sun_04
                  sun_05
                  sun_06
                  sun_07
                  sun_08
                  sun_09
                  [COLOR=#FF0000]sun_010
                  sun_011
                  sun_012[/COLOR]
                  ... but your image objects are labelled as:
                  Code:
                  sun_01
                  sun_02
                  sun_03
                  sun_04
                  sun_05
                  sun_06
                  sun_07
                  sun_08
                  sun_09
                  [COLOR=#FF0000]sun_10
                  sun_11
                  sun_12[/COLOR]
                  So what happens when the count reaches 10? It ignores those last three image objects. So rename your last three image objects to:
                  Code:
                  sun_010
                  sun_011
                  sun_012

                  Comment


                  • #10
                    Hey man.
                    not hard to see what you are doing wrong your variable is "sun_0" so count 1 to 12 relates to sun01 to sun012
                    Change your image names to suit
                    Click image for larger version

Name:	images.png
Views:	102
Size:	13.9 KB
ID:	302179
                    Attached Files

                    Comment


                    • #11
                      Sorry Biohazard sent same time

                      Comment


                      • #12
                        a simple ImageOnSystemKey example



                        ImageOnSystemKey.zip

                        Comment


                        • #13
                          Thank you a lot friends. It helped 100% !
                          Best

                          Comment

                          Working...
                          X
                          😀
                          🥰
                          🤢
                          😎
                          😡
                          👍
                          👎