7 Replies Latest reply on Nov 17, 2011 12:18 PM by Adam-C

    Active Projector and MAIW Scaling

    Jim Wiley Level 1

      Hi All,
      I am creating a CD UI template and I am adding features. I will need to proportionally scale them as a projector and MAIW's. I need to support full screen view too. Each MAIW must scale independently. I have AS2 SWF Player 7. I will have SWF's and FLV files. The Player setting maybe as low as ver. 5 to ver. 10. Less important is that I am looking to always display 100% of SWF and always 100% vertical dim.

      Q1. The Flash Asset (SWF) has a #autoSize setting - How do I insure that the #autoSize is set to default so I can test scaling. I have set it when I Browse and add or update my SWF.

      Q2. What would I have a event handler look for if a user scales the projector? - the Stage?? And if it is a MAIW? Where would I put the one, two or three event handlers?

      Q3. Since this is code I will only write once (and reuse again and again), would any of you like to respond with your versions of code for these two on-the-fly scaling actions for projectors and MAIWs? I find I am spending all my debugging efforts on quirks, exceptions and use of undocumented commands of Director commands for commands/actions I will never code again. I don't really want to re-create wheel. It won't provide any additional Director or programming knowledge other than where these scripts go for me.

      Thanks again,
      Jim

        • 1. Re: Active Projector and MAIW Scaling
          Adam-C Level 2

          A1:

          You can set and check a Flash member's scale property by selecting a Flash member in a cast and then clicking the Flash tab in the properties panel.

          You can test and set this property with Lingo using the scaleMode property (look in the Scripting Dictionary for usage instructions)

           

          A2:

          When the main stage or a MIAW is resized a resizeWindow event is broadcast. You can catch this event in a movie script or a behaviour, for example:

           

          on resizeWindow me

               --do stuff to resize this sprite

          end

           

          The main movie's stage can be accessed from a MIAW by using a tell statement-block directed at the "the stage", for example this script placed in a MIAW will allow you to access scripts, sprites etc. in the main movie:

           

          on sendAMessageToMainMovie

               tell (the stage)

                    sendSprite(1, #doSomething)

                    myChildObject = new script("MyParentScript")

               end tell

               myChildObject.callAHandler(aValue)

          end

           

          Or, if you want to communicate with a MIAW from the main movie or another MIAW:

           

          on sendAMessageToMIAW aWindowName

               window(aWindowName).movie.sprite(1).member.text = "This text has been sent from main movie"

          end

           

          You can also use a tell statement block to communicate with a MIAW from another movie:

           

          on sendAMessageToMIAW aWindowName

               tell window(aWindowName)

                    _movie.sprite(1).member.text = "This text has been sent from another movie"

               end tell

          end

           

          A3:

          The method you choose to handle resizing depends on the nature of your project and your preferred method of working. It's therefore not really possible for me to answer this question for you... and TBH I'd feel like I was giving away a lot or R&D time if I were just to tell you the tricks I use!! But I'll give you a couple of pointers (and TBH you'll learn more by working out the details for yourself )

           

          1) If you want to allow the window to be resized to any size then you need to build a framework that can apply resizing to the objects in your movie. Think in percentages... for example a text box that is positioned at point(100, 100) on a stage that is 1000x1000 could be considered to be positioned at the point x = 10% y =10%. When the user resizes the screen you can translate this percentage position to an absolute pixel position that is calculated from the size of the resized window. The same principle applies to the width and height of your sprites too. Bare in mind, though, that if you are trying to zoom the screen (rather than increase the screen area) then things like Director-native text boxes won't increase their font size unless you also apply this percentage principle to font sizes. Also bare in mind that the calculations you use may-well involve float values, whereas your resulting sprite position / dimensions need to be integer values.

           

          2) If you want to switch to full-screen mode and want the window contents to scale accordingly then it is often easier to resize the user's monitor resolution than it is to create an entire resize framework. You need to consider that the user's monitor could have any one of a number of aspect ratios (4:3, 5:4, 16:9, 16:10 are the most common), but you can get around this by switching your projector to full-screen mode (so that the movie's background colour will fill the screen) and then determining the monitor resolution that most closely matches your movie's native size. Bare in mind that your movie would still be the same size, it's just the it will be presented at a lower pixel resolution. Also, don't forget to restore the user's screen resolution when the movie quits or they'll accuse your program of messing-up their computer.

          Jim Wiley wrote:

           

          I find I am spending all my debugging efforts on quirks, exceptions and use of undocumented commands of Director commands for commands/actions I will never code again.

          Welcome to the wonderful world of Adobe dude

           

          Hope this all helps

          • 2. Re: Active Projector and MAIW Scaling
            Jim Wiley Level 1

            Thanks Adam,

            My eye blew right by the ON RESIZE in my reference docs. It was a single line in a list. I didn't Google RESIZE either. I got fixated on the term SCALE and the STAGE.

            I just got done chasing false event reporting issues with the director's message window and I did not have the patience to find this 'nice to have' feature.

            I am designing a CD and only use Director as a means (through BuddyAPI) to access the local system and launch MAIW's for playing movies and INM's Impressario.

            I am currently using AS2 for the Nav screen so others can do simple editing of text that is displayed and add a lang. I am migrating to AS3 for all the rest design.

             

            I work in 6 month development cycles and I only work on product CD's for 3 weeks in a cycle, mainly on user movies.My last CD design cycle was 5 years ago.

             

            I learn more by doing AS3 and practicing my OOP. Dir is dying and is unique in many ways. Not much pull-through learning/knowledge to be gained.

             

            Thanks again,

            Jim

            • 3. Re: Active Projector and MAIW Scaling
              Adam-C Level 2

              I learn more by doing AS3 and practicing my OOP.

              Yeah, I hear you, but personally I find that Director can be fairly OOP compliant, especially if you make use of parent scripts. Of course, just when you think you're achieving OOP nirvana with Director you'll find yourself having to bodge around some bug or deficiency in a distinctly non-OOP way!

               

              Dir is dying and is unique in many ways. Not much pull-through learning/knowledge to be gained.

              Yeah - Adobe are killing it. It's a damned shame IMO - like you say, so many unique features. I'd disagree about the "pull-through" learning though - I find Lingo such a natural language that I will often do concept prototyping and examples in Director, allowing me to rapidly develop and explore custom class structures, frameworks etc. in an easy, non-compiled environment that's simple to debug and analyse. I'll then recreate these frameworks in their final guise (AS, ObjC, ColdFusion, whatever - depends on the task). I find the ability to test and interact with your code using nothing more than the object inspector and message window an absolute godsend - it's just so much easier than a compiled language in this regard.

               

              Unfortunately Adobe don't see things this way. Personally I think they should sell the source and license to a developer who would give it the attention it deserves and bring it up-to-parr with modern systems. And can you imagine a Director runtime for iOS and/or Android? Producing apps could become as easy as breaking wind!

               

              I'm not holding my breath though (no pun intended!)

              • 4. Re: Active Projector and MAIW Scaling
                Jim Wiley Level 1

                Hi All and Adam-C too,

                I have code now that is working for me now (see below). I will be testing it more thourghly (Win OS's and with other features) when I complete my CD UI design.

                It probably can be simplified. I am just starting to get the feel for where coding elements go and what needs to be modified when passing parameters and variables.

                I also haven't made it generic enough yet for multiple sprites and referencing Sprites (as in I can't use me.spriteNum in place of 1).

                Please feel free to enhace this, correct or clairify it for all of us.

                Thanks,

                  Jim

                ==========================

                on startMovie me
                  global gstartRect, gstartHeight, gstartWidth, gwinRatio
                  set gstartRect=window("stage").sourceRect
                  set gstartWidth = gstartrect.width
                  set gstartHeight = gstartrect.height
                  set gwinRatio = (gstartWidth).float/(gstartHeight).float
                end

                on resizeWindow me
                  global gstartRect, gstartHeight, gstartWidth, gwinRatio
                  set newRect = window("stage").rect
                  set newWidth = newRect.width
                  set newHeight = newRect.height
                 
                  if newWidth < newHeight*gwinRatio then
                    set newHeight = (newWidth *(1/gwinRatio))
                    set newRect.right = newRect.left + newWidth
                    set newRect.bottom = newRect.top + newHeight
                  end if
                 
                  if newWidth > newHeight*gwinRatio then
                    set newWidth = integer(newHeight *(gwinRatio))
                    set newRect.right = newRect.left + newWidth
                    set newRect.bottom = newRect.top + newHeight
                  end if
                 
                  sprite(1).width = newRect.width
                  sprite(1).height = newRect.height
                  sprite(1).locH = sprite(1).width/2
                  sprite(1).locV = sprite(1).height/2
                 
                  window("stage").rect = newRect
                  sendAllSprites(#resize)
                  updateStage
                end

                • 5. Re: Active Projector and MAIW Scaling
                  Adam-C Level 2

                  Hi Jim

                   

                  Is your script in a behavior or a movie script (I.E. do you attach it to your sprites, or does it just sit in a cast library)?

                   

                  Cheers

                  Adam

                  • 6. Re: Active Projector and MAIW Scaling
                    Jim Wiley Level 1

                    Sorry - It is in the Cast Library - Internal as a Movie Script

                    • 7. Re: Active Projector and MAIW Scaling
                      Adam-C Level 2

                      OK - a quick point: The "me" argument should only be passed when calling behaviours or parent scripts - movie scripts are effectively stand-alone global functions / methods ("handlers" in Lingo parlance) that can't refer to themselves (which is what "me" does). So behaviours and parent script instances can be thought of as OOP object instances with their own instance vars and methods (and all comms between these vars and methods can be handled internally to the instance), whilst movie scripts are most like global functions in OOP (although not quite - it would be more accurate to think of them as procedures in procedural programming principles).

                       

                      I'll go through your code and give you some specifics later tonight - it's my tea-time now

                       

                      on isTeaTime me

                           eatDrinkAndEnjoy(me, true)

                      end