8 Replies Latest reply on Aug 11, 2008 10:09 AM by Newsgroup_User

    How tell window to centerStage horizontally only?

    Level 7
      I have been opening a tutorial window directly above an educational
      application to explain how it works. It used to open above the centered
      stage of the main application until I stopped using buddyAPI to set the
      screen resolution to 1024x768. No change is necessary if the user's
      computer is 1024x768 or higher. Now if the application runs on a
      widescreen laptop, the main application opens in the center (which is
      what I want it to do) but the tutor.dcr window opens to the left of the
      main application (the tutor.dir movie size property is 600x150 and the
      position is 200, 10). So if the laptop screen is 1280x800, the main
      app, which is 640x480, centered begins at 320 (1280-640/2), so the tutor
      window beginning at 200 is 120 to the left of the main app. If I tell
      the tutor window to centerStage, it will probably appear centered and in
      front of my main app. How do I center it on the screen horizontally, but
      push it to the top of the screen vertically (so it is above my main app?
      This also has to work given any screen resolution 1024x768 or greater
      in either 4:3 or 16:9 aspect ratio. I can not figure out how to do
      this, so your help would be greater appreciated!
        • 1. Re: How tell window to centerStage horizontally only?
          Level 7
          When you open your window, set its .rect property, and calculate this by
          offsetting the window.sourceRect against _system.desktopRectList[1]. The
          following might get you started:
          -- ...
          tWindow = _player.activeWindow
          tRect = mCenterRectInRect(tWindow.sourceRect, _system.desktopRectList[1])
          tWindow.rect = tRect.offset(0, -tRect.height)
          -- ...


          on mCenterRectInRect r1, r2
          mW = r2.width/2
          mH = r2.height/2
          sW = r1.width/2
          sH = r1.height/2
          return rect(mW - sW, mH - sH, mW + sW, mH + sH)
          end
          • 2. Re: How tell window to centerStage horizontally only?
            Level 7
            Sean Wilson wrote:
            > When you open your window, set its .rect property, and calculate this by
            > offsetting the window.sourceRect against _system.desktopRectList[1]. The
            > following might get you started:
            > -- ...
            > tWindow = _player.activeWindow
            > tRect = mCenterRectInRect(tWindow.sourceRect, _system.desktopRectList[1])
            > tWindow.rect = tRect.offset(0, -tRect.height)
            > -- ...
            >
            >
            > on mCenterRectInRect r1, r2
            > mW = r2.width/2
            > mH = r2.height/2
            > sW = r1.width/2
            > sH = r1.height/2
            > return rect(mW - sW, mH - sH, mW + sW, mH + sH)
            > end

            Ok, I tried placing the above code after my open window (see below) as
            stated and placed the handler in my movie script. When I tried saving
            the movie it gave an error saying that a variable had not been defined.
            I believe it was referring to activeWindow. Can you please tell me
            how to fix this?

            open window (field "urlpath" & "tutor.dcr")
            set the windowType of window (field "urlpath" & "tutor.dcr") to 2
            set the title of window (field "urlpath" & "tutor.dcr") = " "
            tWindow = _player.activeWindow -- this is the line the compiler says
            is in error
            tRect = mCenterRectInRect(tWindow.sourceRect, system.desktopRectList[1])
            tWindow.rect = tRect.offset(0, -tRect.height)
            • 3. Re: How tell window to centerStage horizontally only?
              Level 7
              > open window (field "urlpath" & "tutor.dcr")
              > set the windowType of window (field "urlpath" & "tutor.dcr") to 2
              > set the title of window (field "urlpath" & "tutor.dcr") = " "
              > tWindow = _player.activeWindow -- this is the line the compiler says
              > is in error
              > tRect = mCenterRectInRect(tWindow.sourceRect, system.desktopRectList[1])
              > tWindow.rect = tRect.offset(0, -tRect.height)

              You are using a version earlier than MX 2004 - and should have stated so
              in your initial post.
              --
              win = window (field "urlpath" & "tutor.dcr")
              set the windowType of win to 2
              set the title of win = " "
              tRect = mCenterRectInRect(win.sourceRect, the desktopRectList[1])
              win.rect = tRect.offset(0, -tRect.height)
              open win
              • 4. Re: How tell window to centerStage horizontally only?
                Level 7
                Sean Wilson wrote:
                >> open window (field "urlpath" & "tutor.dcr")
                >> set the windowType of window (field "urlpath" & "tutor.dcr") to 2
                >> set the title of window (field "urlpath" & "tutor.dcr") = " "
                >> tWindow = _player.activeWindow -- this is the line the compiler says
                >> is in error
                >> tRect = mCenterRectInRect(tWindow.sourceRect, system.desktopRectList[1])
                >> tWindow.rect = tRect.offset(0, -tRect.height)
                >
                > You are using a version earlier than MX 2004 - and should have stated so
                > in your initial post.
                > --
                > win = window (field "urlpath" & "tutor.dcr")
                > set the windowType of win to 2
                > set the title of win = " "
                > tRect = mCenterRectInRect(win.sourceRect, the desktopRectList[1])
                > win.rect = tRect.offset(0, -tRect.height)
                > open win

                Sorry Sean, you're right I am using D8. Please do not think ill of me as
                I had no idea that D10 and 11 scripts might not be compatible with prior
                versions. I will know better next time.

                Btw, the tutor window is perfect from left to right but too low on the
                screen vertically so it is in front of the main app on the stage. I
                tried adjusting the second item in the coordinates returned by the
                handler in my movie script. My docs say that the 2nd coordinate is the
                top, so I changed it to 10, but the tutor window is now almost off the
                top of the screen. I could continue to play with it, but I really don't
                think I understand how it works. Could you just give me one more
                adjustment so the tutor window will start just 10 from the top of the
                screen please?

                I tried changing the return to rect(mW - sW, 10, mW + sW, mH + sH), but
                that did not work. Could you please tell me how to change it so the
                tutor window will be almost flush to the top of the screen? And, thank
                you so much for your help!

                on mCenterRectInRect r1, r2
                mW = r2.width/2
                mH = r2.height/2
                sW = r1.width/2
                sH = r1.height/2
                return rect(mW - sW, mH - sH, mW + sW, mH + sH)
                end
                • 5. Re: How tell window to centerStage horizontally only?
                  Level 7
                  Sorry, that should have been (note the change to the offset function):
                  win = window (field "urlpath" & "tutor.dcr")
                  set the windowType of win to 2
                  set the title of win = " "
                  tRect = mCenterRectInRect(win.sourceRect, the desktopRectList[1])
                  win.rect = tRect.offset(0, -tRect.top)
                  open win
                  • 6. Re: How tell window to centerStage horizontally only?
                    Level 7
                    Sean Wilson wrote:
                    > Sorry, that should have been (note the change to the offset function):
                    > win = window (field "urlpath" & "tutor.dcr")
                    > set the windowType of win to 2
                    > set the title of win = " "
                    > tRect = mCenterRectInRect(win.sourceRect, the desktopRectList[1])
                    > win.rect = tRect.offset(0, -tRect.top)
                    > open win

                    Almost there! The tutor window now starts at the top of the screen, but
                    the rectangle is larger than the actual tutor movie so it is overlapping
                    and covering up half of the main stage. The tutor movie is 640x133.
                    The rectangle window looks like its about 640x480. My question now is
                    how do I reduce the height of the tutor window from 480 to 133 so it
                    stays at the top but does not cover up my main movie below. Sorry for
                    so many questions - but I have not worked with a rect like this before.
                    I really do appreciate your help!
                    • 7. Re: How tell window to centerStage horizontally only?
                      Level 7
                      Sean Wilson wrote:
                      > Sorry, that should have been (note the change to the offset function):
                      > win = window (field "urlpath" & "tutor.dcr")
                      > set the windowType of win to 2
                      > set the title of win = " "
                      > tRect = mCenterRectInRect(win.sourceRect, the desktopRectList[1])
                      > win.rect = tRect.offset(0, -tRect.top)
                      > open win

                      Ok, I admit it - I'm retarded, Ph.D. notwithstanding! Adding .top fixed
                      it. I didn't realize it right away, since I had forgotten to remove the
                      retarded code I had added previously to the handler. I figured - oh
                      well - maybe after adding .top I could change the 4th coordinate in the
                      handler to 133 so the tutor movie wouldn't overlap my main movie (as I
                      thought was a problem in my last message - NOT). Then, I discovered the
                      value 10 was still in the handler 2nd coordinate from my lame attempt to
                      push the tutor movie to the top. So, bottom line - I hope you see this
                      before responding to my last false alarm. I wish I could delete the
                      message, but I don't think you can edit or delete posts?

                      Anyhow, Sean - you most definitely know your $#!+ - this is the first
                      time I have really been stuck in Lingo for about ten years and had to
                      rely on this forum. I like snooping in here and was happy the podcast
                      came back - but I hope that some day I will be able to return the favor.
                      Thank you so much!
                      • 8. Re: How tell window to centerStage horizontally only?
                        Level 7
                        Professor posted in macromedia.director.lingo:

                        > Sean Wilson wrote:
                        >> Sorry, that should have been (note the change to the offset function):
                        >> win = window (field "urlpath" & "tutor.dcr")
                        >> set the windowType of win to 2
                        >> set the title of win = " "
                        >> tRect = mCenterRectInRect(win.sourceRect, the desktopRectList[1])
                        >> win.rect = tRect.offset(0, -tRect.top)
                        >> open win
                        >
                        > Almost there! The tutor window now starts at the top of the screen, but
                        > the rectangle is larger than the actual tutor movie so it is overlapping
                        > and covering up half of the main stage. The tutor movie is 640x133.
                        > The rectangle window looks like its about 640x480. My question now is
                        > how do I reduce the height of the tutor window from 480 to 133 so it
                        > stays at the top but does not cover up my main movie below. Sorry for
                        > so many questions - but I have not worked with a rect like this before.
                        > I really do appreciate your help!


                        You might want to look at sourceRect in the docs. It will return the rect
                        tutor.dcr (might want to delete the .dcr in that reference, too).

                        Then base your math on the rect of the stage rather than the monitor.


                        --
                        Mark A. Boyd
                        Keep-On-Learnin' :)