8 Replies Latest reply on Aug 3, 2007 6:33 PM by wgb14

    Change the size of a window that is alredy open

    wgb14 Level 1
      Hi all,

      Is there anyway to change the size (to 800x480) of a window that is already open? Here the code that opens the window:

      HAPwindow2 = window().new("Haptek_player")
      tRect = HAPwindow2.sourceRect
      HAPwindow2.rect = HAPwindow2.sourceRect.offset(190,0) -- d.left, d.top
      HAPwindow2.open()
      end

      I know how to change the size of the movie in the window (window("Haptek_player").movie.sprite(1).rect = rect(0, 0, 800, 480)) but I don't know how to change the size of the window itself. Any ideas?
        • 1. Re: Change the size of a window that is alredy open
          Level 7
          --
          if _player.windowPresent("Haptek_player") then
          window("Haptek_player").rect = [0, 0, 100, 200]
          end if
          • 2. Change the size of a window that is alredy open
            wgb14 Level 1
            Nop... It doesn't work... The Location values that I have for my MIAW is 640 365. If I write window("Haptek_player").rect = rect(0, 0, 800, 480) it changes the size of the window but also its location. I want the location to stay the same (640 365 with an offset of 190 pixels). Any idea what I am doing wrong?
            • 3. Re: Change the size of a window that is alredy open
              Level 7
              > Nop... It doesn't work... The Location values that I have for my MIAW is 640 365. Any idea why?

              A window doesn't have a location as such, rather it is governed by its rect.
              I have no idea why the snippet I posted isn't working for you. Perhaps
              the window name is different, or it isn't open, or...
              What debugging options have you tried so far?
              • 4. Re: Change the size of a window that is alredy open
                wgb14 Level 1
                I don't have a clue how to debugg this.... here is the complete code:

                on haplayer1

                if _player.windowPresent("Haptek_player") then
                window("Haptek_player").rect = [0, 0, 100, 200]
                window("Haptek_player").movie.sprite(1).rect = rect(0, 0, 800, 480)
                end if

                it changes the stage correctly but it fails to change the size of the window.... By the way from where did you get the values 100 and 200?
                • 5. Re: Change the size of a window that is alredy open
                  wgb14 Level 1
                  >A window doesn't have a location as such, rather it is governed by its rect.

                  By the way with location i mean that i have set the location fields in the MIAW property inspector to 640 365 and then my code places the window to the same coordinates but with an ofset of 190 pixels...
                  • 6. Re: Change the size of a window that is alredy open
                    Level 7
                    > I don't have a clue how to debugg this.... here is the complete code:

                    You could use 'put' statements if you have a message window available,
                    or 'alert's sprinkled throughout.

                    > on haplayer1
                    >
                    > if _player.windowPresent("Haptek_player") then
                    > window("Haptek_player").rect = [0, 0, 100, 200]
                    > window("Haptek_player").movie.sprite(1).rect = rect(0, 0, 800, 480)
                    > end if
                    >
                    > it changes the stage correctly but it fails to change the size of the
                    > window....

                    Are you running this window as the stage? The code above shouldn't
                    affect the stage unless the name of the stage window is "Haptek_player"

                    > By the way from where did you get the values 100 and 200?

                    They were intended for you to change.
                    Perhaps you might try:
                    if _player.windowPresent("Haptek_player") then
                    window("Haptek_player").rect = rect(0, 0, 800, 480).offset(190,0)
                    end if
                    • 7. Change the size of a window that is alredy open
                      wgb14 Level 1
                      The window moves from its location to the upper left side of the stage (unknown why). I will try to debug but if you have any other suggestions please let me know.. Many thanks for your replies so far...


                      OK... here is what put(window("Haptek_Player").rect) gives me for the original window (830,365,1230,685) and after the code moves the window to the upper top left corner of the stage (7,99,807,579)
                      • 8. Re: Change the size of a window that is alredy open
                        wgb14 Level 1
                        Here is the answer:

                        on haplayer2

                        tRect = window("Haptek_player").sourceRect.offset(190,0)

                        if _player.windowPresent("Haptek_player") then

                        window("Haptek_player").rect = tRect + rect(0,0,624,280) -- left, top, right and bottom 400 165-- tRect.offset(190,0)
                        window("Haptek_player").movie.sprite(1).rect = rect(0, 0, 1024, 600)

                        end if
                        end


                        The values 624,280 come if you substract the resolution that you want to achieve from the window's original dimensions (in my case 400 x 320).